如何解决getThemedContext()和getSupportFragmentManager()

时间:2015-04-05 13:06:59

标签: java android navigation-drawer

我想在我的项目中添加导航抽屉,但是当我使用此代码时,我遇到getThemedContext()getSupportFragmentManager()的问题。

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActionBar().getThemedContext(), android.R.layout.simple_list_item_1, data);
    final DrawerLayout drawer = (DrawerLayout)findViewById(R.id.drawer_layout);
    final ListView navList = (ListView) findViewById(R.id.drawer);
    navList.setAdapter(adapter);
    navList.setOnItemClickListener(new AdapterView.OnItemClickListener(){
        @Override
        public void onItemClick(AdapterView<?> parent, View view, final int pos,long id){
            drawer.setDrawerListener( new DrawerLayout.SimpleDrawerListener(){
                @Override
                public void onDrawerClosed(View drawerView){
                    super.onDrawerClosed(drawerView);
                    FragmentTransaction tx = getSupportFragmentManager().beginTransaction();
                    tx.replace(R.id.main, Fragment.instantiate(msgBox.this, fragments[pos]));
                    tx.commit();
                }
            });
            drawer.closeDrawer(navList);
        }
    });
    FragmentTransaction tx = getSupportFragmentManager().beginTransaction();
    tx.replace(R.id.main,Fragment.instantiate(msgBox.this, fragments[0]));
    tx.commit();

0 个答案:

没有答案