如何为选定的导航抽屉列表项片段调用FragmentActivity

时间:2015-05-02 11:04:26

标签: android-fragments android-fragmentactivity

直升机。 我刚看看androidhive.info并获取代码SlideMenu。现在我将SlideMenu与TabBar集成在一起。 这是我的SlideMenu Fragment代码来获取选择:

/**
     * Diplaying fragment view for selected nav drawer list item
     * */
    private void displayView(int position) {
        // update the main content by replacing fragments
        Fragment fragment = null;
        switch (position) {
        case 0:
            fragment = new HomeFragment();
            break;
        case 1:
            fragment = new FindPeopleFragment();
            break; 

        default:
            break;
        }

        if (fragment != null) {
            FragmentManager fragmentManager = getFragmentManager();
            fragmentManager.beginTransaction()
                    .replace(R.id.frame_container, fragment).commit();

            // update selected item and title, then close the drawer
            mDrawerList.setItemChecked(position, true);
            mDrawerList.setSelection(position);
            setTitle(navMenuTitles[position]);
            mDrawerLayout.closeDrawer(mDrawerList);
        } else {
            // error in creating fragment
            Log.e("MainActivity", "Error in creating fragment");
        }
    }

现在在我的HomeFrament:

public abstract class HomeFragment extends FragmentActivity implements
ActionBar.TabListener {

    private ViewPager viewPager;
    private TabsPagerAdapter mAdapter;
    private ActionBar actionBar;
    // Tab titles
    private String[] tabs = { "Top Rated", "Games", "Movies" };

我得到了错误:

  

无法实例化HomeFragment类型

如何使用FragmentActivity对片段进行调整?请帮我。感谢。

0 个答案:

没有答案