I’m beginner in Java Android developing. I’m using Eclipse SDK 3.6.1 version. I’m trying to this: first class is watching a two RadioButtons status from second class. I’m trying to set RadioButton status when they are not clicked.
First class:
public void onClick(View view) {
switch (view.getId()) {
case R.id.Button01:
if (toolsas.rb1.isChecked()) { //do something
Second class with RadioButtons:
public void onClick(View view) {
switch (view.getId()) {
case R.id.RadioButton01:
rb1=(RadioButton)findViewById(R.id.RadioButton01);
rb2=(RadioButton)findViewById(R.id.RadioButton02);
if (rb1.isChecked()) {
rb2.setChecked(false);
rb1.setChecked(true);
When I click a RadioButton rb1 and change him status to checked the first class is working, bet how to set status when I don’t click RadioButton rb1? If I firstable click Button01 the program is stopped. First class have few buttons, when I push the Button01 I can call a second class and change some options
Sorry for the bad english
Its pretty hard to figure out what you are trying to do, but I think you have two different layouts, each of which has a different radio button. I think you want them to have opposite status, so that when a user checks one, the other will appear unchecked?
If so, one way to do this is to save the state of the checkboxes to
SharedPreferences. Whenever the user changes the setting of a checkbox, save its state intoSharedPreferences. Whenever you load one of yourActivitesyou can then read the value from your preferences and set the UI to match.