导航抽屉片段将我的活动放在android中

时间:2015-12-18 11:11:36

标签: android android-activity

我是非常新的android,首先抱歉我的英文不好,我在android studio 1.4上使用默认导航抽屉它工作正常,但是当我点击导航抽屉项目我想显示活动有标签任何一个请帮助我 这里是我的导航grawer代码

 @SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_camara) {
        MainFragment fragment=new MainFragment();
        android.support.v4.app.FragmentTransaction fragmentTransaction=
                getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.fragment_container,fragment);
        fragmentTransaction.commit();

    } else if (id == R.id.nav_gallery) {


        GalleryFragment fragment=new GalleryFragment();
        android.support.v4.app.FragmentTransaction fragmentTransaction=
                getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.fragment_container,fragment);
        fragmentTransaction.commit();

如果我点击相机项目,它会显示标签,任何人都可以帮助我如何实现

1 个答案:

答案 0 :(得分:0)

您也可以尝试此演示:SlidingMenu