0

Lets say that i am having main activity as

public class home_activity extends ActionBarActivity {
    EditText t1;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.home_layout);
        t1=(EditText)findViewById(R.id.status);
        t1.setText("single");
    }
}

Now i have another activity that contain radio group. In that radio group contains 3 radio button single, married,divorce. If there is change using in radio group the t1 should be changed.The second activity as follow.

public class another_activity extends ActionBarActivity {
    RadioGroup g1;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.another_layout);
        g1=(RadioGroup)findViewById(R.id.radiogroup);
        g1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                //here what should i do to get result when user checks married or divorce radio button in another activity
            }
        });
    }
}
akmozo
  • 9,829
  • 3
  • 28
  • 44

1 Answers1

0

You can use Preferences(Google it up) to store the marital status from your another_activity and load it from the preferences and display it on textView of the main Activity.

Incase the flow of your application is something like this,

Home_activty -> Another_Activity (after the user makes the status seclection),
you return back to the home_Activity (i.e)
Another_Activity ->Home_Activity

Then the solution is to start another_activity for result by the method

startAcitivtyForResult();

Reference: How to manage `startActivityForResult` on Android?

http://developer.android.com/training/basics/intents/result.html

Community
  • 1
  • 1
Ashwin Surana
  • 826
  • 3
  • 10
  • 33