JimboJones21
Lurker
Hello everyone! This part of code doesn't seem to be working, particularly the method isChecked(), because I have imported checkBox id as static import static todo.beginner.com.carchoose.R.id.checkBoxPrice;, but if checkBox is defined under class then the app is crushing when button is pressed to launch second activity. Also textView1 is in the SecondActivity, but check boxes are in MainAcitivy. Is there some way of making this part work and keeping checkbox imported as static? Here is a part from MainActivity.java:
Code:
initialUISetup();
}
public void initialUISetup() {
CheckBox checkBoxPrice = (CheckBox) findViewById(R.id.checkBoxPrice);
CheckBox checkBoxGas = (CheckBox) findViewById(R.id.checkBoxGas);
CheckBox checkBoxYear = (CheckBox) findViewById(R.id.checkBoxYear);
CheckBox checkBoxMileage = (CheckBox) findViewById(R.id.checkBoxMileage);
CheckBox checkBoxCapacity = (CheckBox) findViewById(R.id.checkBoxCapacity);
checkBoxPrice.setOnCheckedChangeListener(new myCheckBoxChangeClicker());
checkBoxGas.setOnCheckedChangeListener(new myCheckBoxChangeClicker());
checkBoxYear.setOnCheckedChangeListener(new myCheckBoxChangeClicker());
checkBoxMileage.setOnCheckedChangeListener(new myCheckBoxChangeClicker());
checkBoxCapacity.setOnCheckedChangeListener(new myCheckBoxChangeClicker());
}
class myCheckBoxChangeClicker implements CheckBox.OnCheckedChangeListener
{
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if(checkBoxPrice.isChecked() || checkBoxGas.isChecked() || checkBoxYear.isChecked() || checkBoxMileage.isChecked() || checkBoxCapacity.isChecked())
{
textView1.setText("Audi");
}
}
}