我需要使用活动堆叠吗?
Do i need to use stacking of activities?
我这里有个问题,我不知道为什么会这样。
activity A - login
activity B - list
activity C - profile
1. I have an activity A, B and C.
2. From activity A, I can open activity B.
3. From activity B, i can open activity C.
4. When I press the back from activity C, it goes back to activity A and I want it to be in activity B.
片段来自 activity C:
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed();
}
片段来自 activity B:
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
Log.d("Clicked item id", " "+ id);
Intent i = new Intent(getApplicationContext(), ChildProfile.class);
startActivity(i);
finish();
}
片段来自 activity A:
Intent i = new Intent(getApplicationContext(),Children.class);
startActivity(i);
finish();
当你打开 Activity C 你正在完成 Activity B
所以只需从 Activity B class 代码中删除 finish()
。当你调用 Intent
有关详细信息,请参阅以下内容 link
http://developer.android.com/guide/components/tasks-and-back-stack.html
加入Activity C
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
Intent i = new Intent(C.this, B.class);
startActivity(i);
super.onBackPressed();
}
或删除 Activity B
中的 finish();
我这里有个问题,我不知道为什么会这样。
activity A - login
activity B - list
activity C - profile
1. I have an activity A, B and C.
2. From activity A, I can open activity B.
3. From activity B, i can open activity C.
4. When I press the back from activity C, it goes back to activity A and I want it to be in activity B.
片段来自 activity C:
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed();
}
片段来自 activity B:
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
Log.d("Clicked item id", " "+ id);
Intent i = new Intent(getApplicationContext(), ChildProfile.class);
startActivity(i);
finish();
}
片段来自 activity A:
Intent i = new Intent(getApplicationContext(),Children.class);
startActivity(i);
finish();
当你打开 Activity C 你正在完成 Activity B
所以只需从 Activity B class 代码中删除 finish()
。当你调用 Intent
有关详细信息,请参阅以下内容 link
http://developer.android.com/guide/components/tasks-and-back-stack.html
加入Activity C
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
Intent i = new Intent(C.this, B.class);
startActivity(i);
super.onBackPressed();
}
或删除 Activity B
finish();