【问题标题】:Android - Calling Activity into Fragments - Navigation DrawerAndroid - 将活动调用到片段中 - 导航抽屉
【发布时间】:2014-02-04 15:19:01
【问题描述】:

我已经从 Android 官方网站http://developer.android.com/training/implementing-navigation/nav-drawer.html 下载了示例项目。我试图了解导航抽屉的工作原理。所以,我有一个疑问,他们从左侧菜单中为每个项目调用一个片段。在我的项目中,我有一个很大的活动,我试图用这个片段来调用它:

公共类 HomeFragment 扩展片段 {

public HomeFragment() {
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    Intent intent = new Intent();
    intent.setClass(getActivity(), ListMatch.class);
    startActivity(intent);
    View rootView = inflater.inflate(R.layout.list_match, container, false);
    return rootView;
}

}

但是,如果我这样做,它会完美地调用我的 Activity,但菜单会消失。如何调用此活动并保留我的菜单?非常感谢。

【问题讨论】:

  • 你还需要有活动的抽屉。或者有一个带抽屉的 BaseActivity,其他活动从 BaseActivity 扩展

标签: android android-fragments android-activity fragment drawer


【解决方案1】:

就像 Raghunandan 所说,抽屉适用于单个活动。从“主”抽屉启动一个新活动是很常见的,但通常这种活动会在操作栏中设置向上操作以返回主活动。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-03
    • 1970-01-01
    • 2022-01-10
    • 1970-01-01
    • 1970-01-01
    • 2016-07-04
    相关资源
    最近更新 更多