Button Problem :'(

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Button Problem :'(

Postby Zargle » Fri Dec 25, 2009 3:50 am

I have a button called "savebutton" and in oncreate of my activity I tried to get a handle to it but R.id doesn't
resolve. I tried in 2.0, 2.0.1 and 1.5 and all have the same problem after converting the code through the versions.

The area of problem:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  public void onCreate(Bundle savedInstanceState)
  2.  
  3.     {
  4.  
  5.         super.onCreate(savedInstanceState);
  6.  
  7.         this.setContentView(R.layout.main);
  8.  
  9.         Button b;
  10.  
  11.         b=(Button) this.findViewById(R.id.savebutton);
  12.  
  13.         b.setOnClickListener(this);
  14.  
  15.  
  16.  
  17.     }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


My main.xml:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <Button
  2.  
  3. android:text="Save Button"
  4.  
  5. android:id="@+id/savebutton"
  6.  
  7. android:layout_width="wrap_content"
  8.  
  9. android:layout_height="wrap_content">
  10.  
  11.  </Button>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
Zargle
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Dec 25, 2009 3:45 am

Top

Postby achie1266 » Fri Dec 25, 2009 8:53 am

what does your logcat say? your code for fetching the button looks fins. So it would be more helpful if you post your logcat message.

Apart from that the other issue would be passing this setOnClickListener method. You need to overwrite the OnClickListener Interface and pass that to you setOnClickListener method.

I do not think you need to change versions for this issue.
achie
User avatar
achie1266
Master Developer
Master Developer
 
Posts: 223
Joined: Mon Nov 09, 2009 10:56 pm
Location: Denver

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests