I have 2 Activities, Activity_A and Activity_B
Activity_A has a checkBox and a Button
what i am trying to do is when i click a Activity_A_button Activity_B would start
Depending on Activity_A checkBox state a TextView is visible or Gone.
here is a sample code
public class Main extends Activity {
public static CheckBox check1;
private Button Button1;
CheckBox check1 = (CheckBox)findViewById(R.id.checkBox1);
Button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
final Intent i = new Intent(this, Activity_A.class);
startActivity(i);
}
});
Activity_B
Textview1 = (TextView)findViewById(R.id.textView1);
if (Main.check1.isChecked())
{
//code here
}
the problem is that i am getting a NullPointerExeption when i click Activity_A button @ the if statement
any ideas? thanks in advance
Do something like this.
send the value of the checkbox when calling the activity.then retrieve it from your second activity and work accordingly