DrawerLayout not working in 2.3 Device

前端 未结 2 1304
我在风中等你
我在风中等你 2021-01-05 04:32

Hello Friends i implement one Demo Applicaiton for DrawerLayout in All Android Device

MainClass as below :

import java.util.Locale;

import android.         


        
相关标签:
2条回答
  • 2021-01-05 04:41

    Stuck in the same problem from the same tutorial after applying all the suggestions of the other answers, I've found (a few moments ago) that it's the invalidateOptionsMenu(); too that creates a problem. You've to use the supportInvalidateOptionsMenu(); and it magically works.

        mDrawerToggle = new ActionBarDrawerToggle(
            this,                  /* host Activity */
            mDrawerLayout,         /* DrawerLayout object */
            R.drawable.ic_drawer,  /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open,  /* "open drawer" description for accessibility */
            R.string.drawer_close  /* "close drawer" description for accessibility */
            ) {
        public void onDrawerClosed(View view) {
            getSupportActionBar().setTitle(mTitle);
            supportInvalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    
        public void onDrawerOpened(View drawerView) {
            getSupportActionBar().setTitle(mDrawerTitle);
            supportInvalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
        };
    
    0 讨论(0)
  • 2021-01-05 04:50

    The problem lies in the drawer_list_item.xml. You will need to remove these 2 lines:

    android:background="?android:attr/activatedBackgroundIndicator"
    android:minHeight="?android:attr/listPreferredItemHeightSmall"
    

    Once those are removed it should work. Both of these items need later api versions to work correctly.

    0 讨论(0)
提交回复
热议问题