0

im trying to connect between my xml code to my java code on eclispe. i have a button called bt1. when im trying to do R.id.bt1- it doesnt recognize the bt1. meaning it did not get the xml code.. can you see wats wrong?

XML:`

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
   android:text="@string/hello_world" />
<Button 
    android:id="@+id/bt1"   
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"

    />

`

JAVA:

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button btn=(Button) findViewById(R.id.bt1);
4
  • Doesn't look like anything is wrong. What are you trying to get the button to do exactly? Also, do you get an error whenever you run this? Commented Jul 25, 2013 at 3:11
  • 2
    will you please just do clean and build project. Commented Jul 25, 2013 at 3:12
  • If your layout file name is activity_main.xml, then a clean and re-build should solve the problem as suggested by Brijesh. Commented Jul 25, 2013 at 3:38
  • "it did not get the xml code". What does it mean? Commented Jul 25, 2013 at 4:10

1 Answer 1

1

Please remove (`) after semicolon(;) from

Button btn=(Button) findViewById(R.id.bt1);`

Sign up to request clarification or add additional context in comments.

1 Comment

i dont think i had any (') in the end of the line. do you see any other reason for the dismatch?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.