Results 1 to 2 of 2

Thread: R.id

  1. #1
    Niv99 is offline Member
    Join Date
    Feb 2014
    Posts
    3
    Rep Power
    0

    Angry R.id

    i trid to do R.id.
    this is the code:

    package com.example.myfirstapp;

    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Menu;
    import android.widget.Button;
    import android.widget.TextView;

    public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    counter = 0;
    add = (Button)findViewById(R.id.You)






    }

    int counter;
    Button add, sub;
    TextView YOU;


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
    }

    }

    the system not finde id that called You

    this is the layout code:
    <TextView
    android:id="@+id/You"

    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:gravity="center"
    android:text="your total is 0"
    android:textSize="45dp"


    what is the problem?

  2. #2
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: R.id

    That can't be all of the layout code. If it is, that's your problem.

    If there is an error anywhere in any of the layout XML files, the build will halt before the R class is generated and you'll get errors similar to that. If you're using Eclipse, check if it shows any error in the res/ folder.
    Get in the habit of using standard Java naming conventions!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •