getting nullpointer exception when click on button
Posted
by
user1315187
on Stack Overflow
See other posts from Stack Overflow
or by user1315187
Published on 2012-04-05T12:11:38Z
Indexed on
2012/04/06
11:28 UTC
Read the original article
Hit count: 192
I am use a button and when u click this button a text field is automatic created and button status is automatic disable but if u click on disable button text field is automatic delete and button status is changed to enable.i going through this process.
public class ConfigurationScreen extends MainScreen implements FieldChangeListener{
TextField tf_text;
tf_text = new
TextField(TextField.TYPE_PLAIN,img_text[1],img_text[0],TextField.FIELD_HCENTER);
tf_text.setWidth(Display.getWidth()/2+20);
ImageButton btn_en;
btn_en = new ImageButton(imgs_tmintrvl1,"enable",ImageButton.FIELD_HCENTER);
ImageButton btn_dis;
btn_dis=new ImageButton(imgs_tmintrvl1,"Disable",ImageButton.FIELD_HCENTER);
add(btn_en);
btn_en.setChangeListener(this);
public void fieldChanged(Field field, int context) {
if( field==btn_en)
{
delete(btn_en);
insert(btn_dis, 4);
insert(tf_text, 5);
System.out.println(ex);
}else if (field == btn_dis){
delete(btn_dis);
delete(tf_text);
insert(btn_en, 4);
System.out.println("Disable Button="+ex);
}
}
But when i run this code i am getting null pointerr exception please help me where i am making mistake.
Thanks in Advance
© Stack Overflow or respective owner