setOnClickListner
I am totally new to Android development , recently i bought Lynda.com Android App Development video learning course.
I am facing following problem:
- Created new project
- Created new xml file with text field only
- Then go to Main.xml(that was created by defualt) and replace the default text field with button.
- Then go to Main.Java and try calling added button by code "Button b = (Button) findVie开发者_StackOverflow社区wById(android.R.id.button1);"
- After that I tried to call the setOnClickListner function by " b. " but there is no option with name of setOnClickListner.
I follow the exact steps as told by tutor in videos .. I am using Android SDK 12 ,Eclipse Indigo and working on Gingerbread 2.3.3. Any solution in this regard would be appreciated
Possible situations:
- Make sure you imported android.widget.Button
-
"Button b = (Button) findViewById(android.R.id.button1);"
Usually it is called:
"Button b = (Button) findViewById(R.id.button1);"
if you have defined the button correctly in the main.xml file. Also make sure you are not importing android.R
- I suppose it is a typo but it is actually written setOnClickListener()
Cheers
精彩评论