1

自己看: 三星Galaxy S3

**

三星Galaxy S3

**

带有 API19 的模拟器

**

带有 API 19 的模拟器!

**

我不明白为什么会这样,哦,我用摩托罗拉测试过,我完全忘记了型号;它工作得很好,但就像我说的那样;不在 S3、S4、Nexus 5 上...

你能解释一下吗?

这是代码:

drawer = (DrawerLayout)findViewById(R.id.DrawerLayout);
    menu = (ListView)findViewById(R.id.Menu);
    listElements = getResources().getStringArray(R.array.listElements);

    //Relier le menu (listview) avec un adapter: (context, layout d'un element d'une liste, les elements a inserer)
    menu.setAdapter(new  ArrayAdapter <String>(this, R.layout.item_list1, listElements));


//------------------Instanciation du toggle (Utilisation d'une classe anonyme)----------------------------------------
    toggle = new ActionBarDrawerToggle(
            this, drawer,
            R.drawable.ic_drawer,
            R.string.open,
            R.string.close){

            //Après fermeture !<
        public void onDrawerClosed(View v){
            super.onDrawerClosed(v);
            getActionBar().setTitle(title);
            invalidateOptionsMenu();
        }
        //Après l'ouverture:
        public void onDrawerOpened(View v){
            super.onDrawerOpened(v);
            getActionBar().setTitle("Menu de l'application");
            invalidateOptionsMenu();
        }
    };//----------------------------------------------------------------------

    //togge --> drawerListener; puisque la classe ActionBarDrawerToggle hérite de la classe DrawerListener

    drawer.setDrawerListener(toggle);       
    getActionBar().setDisplayHomeAsUpEnabled(true);  

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    // Sync the toggle state after onRestoreInstanceState has occurred.
     toggle.syncState();
}

///////////////////////////////////////// //////////////////

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/DrawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
            <include
        android:id="@+id/ContenuPrincipal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        layout="@layout/activity_main_relative"
        /> 

    <!-- ListView... La liste des options du menu -->
       <ListView
            android:id="@+id/Menu"
            android:layout_width="250dp"
            android:layout_height="fill_parent"
            android:choiceMode="singleChoice"
            android:layout_gravity="start"
            android:background="#333"
            android:divider="#666"
            android:dividerHeight="1dp"
            android:paddingLeft="15dp"
            android:paddingRight="15dp"
            />  


</android.support.v4.widget.DrawerLayout>

我认为项目的 XML 文件在这里并不重要,所以.. 好的,我认为我已经把所有重要的东西都放在了这里。我希望我的问题很清楚。谢谢

4

1 回答 1

-1

ActionBarDrawerToggle我有完全相同的问题,并通过在初始化对象之前添加以下内容来解决它。

ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
于 2014-03-31T10:54:50.350 回答