Hi Android Experts,
why CheckBox is always null.
please find the error in my code:
xml-
<CheckBox id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
code file-
package com.reblogr.reblogrclient;
public class Test extends Activity {
/** Called when the activity is first created. */
public CheckBox checkbox;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
Button connectButton = (Button)findViewById(R.id.objBtn1);
checkbox= (CheckBox)findViewById(R.id.checkbox);
connectButton.setOnClickListener(connectButtonListener);
}
public OnClickListener connectButtonListener = new OnClickListener
()
{
public void onClick(View v)
{
Athenticate();
}
};
public void Athenticate(){
if(checkbox.isChecked()){ //
NullPointerException here
//do something
}
}
}
why checkbox is null?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---