0

I am experimenting with TabHost and ActivityGroup when I noticed that if I pressed back on one activity, the whole ActivityGroup is destroyed. As such, I created a list of Views representing my activities. However, this causes my previous activity to lost its state. I even setup the freezesText of my EditText on the previous activity to 'true' but this does not help in preserving its value.

Can you explain me how the ActivityGroup works and how it manages it sub-activities? Right now, I get the impression that ActivityGroup only switches the views, not activities. Am I correct with that? I am getting more and more confused here. How can I make it work such that if I pressed back on one activity, the previous activity will be recovered based on its last state? (Like what happens when a normal activity calls another activity then the user presses back.)

This is what I want to happen:

  • ActivityGroupA (ActivityGroupA was launched. User inputs details on ActivityGroupA.)
  • ActivityGroupA > ActivityB (User presses 'submit'. ActivityGroupA calls ActivityB.)
  • ActivityB > ActivityGroupA (User presses 'cancel'. ActivityB is destroyed. ActivityGroupA is now the top of the stack again.)

Is this possible? How can I do it?

Arci
  • 6,647
  • 20
  • 70
  • 98

1 Answers1

0
public void back()
{
    if ( history.size() > 1 )
    {
        history.remove(history.size() - 1);
        View v = history.get(history.size() - 1);
        v.setFocusable(true);
        v.setFocusableInTouchMode(true);
        v.clearFocus();
        setContentView(v);
    }
    else 
        this.finish();
}
Community
  • 1
  • 1