我打開「活動A」。 「活動A」立刻做了FragmentTransaction
這樣打開「片段A」:無法添加到片段Back Stack
FragmentTransaction t = fm.beginTransaction();
ListFragment f = new ProfileFragment();
t.replace(R.id.main_frag, f, "act_frag");
f.setArguments(args);
t.commit();
「片段A」上有一個按鈕,我想開一個新的Fragment
(「片段B」),但將「片段A」放在後臺 - 所以如果用戶回擊,它仍然在附近。所以我這樣做:
FragmentTransaction t = fm.beginTransaction();
ListFragment f = new FollowFragment();
String username = tvUser.getText().toString();
Bundle args = new Bundle();
args.putString("follow", "watching");
args.putString("userprofile", username);
args.putInt("userIdprofile", userId);
f.setArguments(args);
t.replace(R.id.main_frag, f, "watching_frag");
t.addToBackStack("watching_frag");
t.commit();
我想加入t.addToBackStack(null);
會做的伎倆;我之前就這樣做過。但是,當用戶反擊時,它只是關閉「活動A」。
我認爲你是對的。讓我添加並看看。 – KickingLettuce 2014-10-27 17:57:28
就是這樣,謝謝。標記正確。 – KickingLettuce 2014-10-27 18:03:32
等待..是用於添加「片段A」或「活動」中發生的「片段B」的片段事務嗎? – Eric 2014-10-27 18:03:44