如何在android fragmentTabHost中返回片段

时间:2015-05-15 10:10:57

标签: android fragment-tab-host

我画了这个问题:

enter image description here

有人知道解决方案吗?

1 个答案:

答案 0 :(得分:1)

使用startActivityForResultActivityB开始ActivityA

int REQUEST_CODE = 99; // random number here
startActivityForResult(activityAIntent, REQUEST_CODE);

1)在ActivityB电话:

  setResult(RESULT_OK);
  finish();

2)来自ActivityA的{​​{1}}抓住RESULT_OK

ActivityB

其他解决方案如果您在开始@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // Check which request we're responding to if (requestCode == REQUEST_CODE) { // Make sure the request was successful if (resultCode == RESULT_OK) { // finish ActivityA and navigate back to FragmentA setResult(RESULT_OK); finish(); } } } 后不需要ActivityA,请在ActivityB中致电finish() ActivityA。完成后,您只需拨打ActivityB中的finish(),用户就会按预期导航回ActivityB