【发布时间】:2014-02-28 17:05:56
【问题描述】:
我有以下活动在选择选项卡时启动片段:
public class MainActivity extends Activity implements TabListener {
Fragment f = null;
.....
public void onTabSelected(Tab tab, FragmentTransaction ft) {
.....
if (tab.getPosition() == 0) {
if (initalSync == true) {
progress1.setVisibility(TRIM_MEMORY_UI_HIDDEN);
}
f = new EventFragment();
Bundle data = new Bundle();
data.putInt("idx", tab.getPosition());
f.setArguments(data);
}
if (tab.getPosition() == 1) {
progress1.setVisibility(TRIM_MEMORY_UI_HIDDEN);
f = new MapsFragment();
Bundle data = new Bundle();
data.putInt("idx", tab.getPosition());
f.setArguments(data);
}
.....
ft.replace(android.R.id.content, f);
}
每当我按下任何片段上的手机后退按钮时,它都会关闭我的应用程序。我知道这与 backstack 有关,但我尝试过的每种方法都失败了。
有什么想法吗?
【问题讨论】:
-
你能发布错误吗?
-
运行应用时没有错误,只有当我按下返回按钮并且整个应用关闭时
标签: android android-fragments android-actionbar fragment back-stack