Attempt to invoke virtual method 'android.text.Editable android.widget.EditText.getText()' on a null object reference

前端 未结 3 1180
既然无缘
既然无缘 2021-01-12 05:42

I have tried all possible cases but not solved , Need suggestions

public class WolfActivity extends ActionBarActivity {

   EditText fname_ele,lname_ele,ema         


        
相关标签:
3条回答
  • 2021-01-12 06:03

    add this line after setContentView:

    pwd_ele=(EditText) findViewById(R.id.password);
    
    0 讨论(0)
  • 2021-01-12 06:03
    EditText fname_ele,lname_ele,email_ele,phone_ele,pwd_ele,fax_ele,addr_ele,
             addr1_ele,city_ele,zipcode_ele,facility_ele,state_ele;
    

    Notice that you are lacking 1 EditText that you have declared above. You missed initializing the String pwe_ele in the onCreate method.

            fname_ele=(EditText) findViewById(R.id.first_name);
            lname_ele=(EditText) findViewById(R.id.last_name);
            email_ele=(EditText) findViewById(R.id.email);
            button=(Button) findViewById(R.id.submit_button);
            phone_ele=(EditText) findViewById(R.id.phone);
            addr_ele=(EditText) findViewById(R.id.address);
            addr1_ele=(EditText) findViewById(R.id.address1);
            fax_ele=(EditText) findViewById(R.id.fax);
            facility_ele=(EditText) findViewById(R.id.facility);
            zipcode_ele=(EditText) findViewById(R.id.zip);
            city_ele=(EditText) findViewById(R.id.city);
            state_ele=(EditText) findViewById(R.id.state);
    
    0 讨论(0)
  • 2021-01-12 06:17

    You have 12 EditText declared but you've initialized 11

    You forgot to initialize pwd_ele

    0 讨论(0)
提交回复
热议问题