samedi 5 septembre 2015

Android: Getting Checkbox value from Parent Activity

I have one parent Activity, which has following code.

void parentMethod(){
    c1=(CheckBox)findViewById(R.id.checkBox1);
    c2=(CheckBox)findViewById(R.id.checkBox2);
    c3=(CheckBox)findViewById(R.id.checkBox3);
   if(c1.isChecked()){
        p.setC1("1");
   }
   if(c2.isChecked()){
        p.setC2("1");
   }
   if(c3.isChecked()){
        p.setC3("1");
   }
}

Here c1,c2,c3 are checkboxes.

Now I have one child activity which is extending above mentioned parent activity.

void childMethod(){
     super.parentMethod();
}

It's giving me java.lang.NullPointerException at 'if(c1.isChecked()){' in parent method.

Is there any way I can get the checkbox values from parent class?

Aucun commentaire:

Enregistrer un commentaire