Android Navigation: Menus, ActionBar/ToolBar, and Navigation Drawer Ro’zimurodov Nodirjon


android:choiceMode="singleChoice"/>



Download 0,86 Mb.
bet6/7
Sana13.12.2022
Hajmi0,86 Mb.
#885109
1   2   3   4   5   6   7

android:choiceMode="singleChoice"/>

DrawerLayout Java

  • The listview is setup like normal
    • Except on a selection, we also close the drawer.
    • mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

      In the setOnItemClickListener use mDrawerLayout.closeDrawers();

  • We need to tie the drawer to the actionbar, so the icons show, uses the ActionBarDrawerToggle.

DrawerLayout Java (2)

  • enable ActionBar app icon to behave as action to toggle nav drawer
  • getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    getSupportActionBar().setHomeButtonEnabled(true);

  • ActionBarDrawerToggle ties together the proper interactions between the sliding drawer and the action bar app icon
  • mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */

    mDrawerLayout, /* DrawerLayout object */

    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(R.string.app_name); //change the title back , when closed.

    invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()

    }

    public void onDrawerOpened(View drawerView) {

    getSupportActionBar().setTitle("Categories"); //change the name, when opened.

    invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()

    } };

    mDrawerLayout.setDrawerListener(mDrawerToggle);

DrawerLayout Java (3)

  • Lastly, these two or it doesn’t drawer correctly in the actionbar/toolbar.
  • /**

    * When using the ActionBarDrawerToggle, you must call it during

    * onPostCreate() and onConfigurationChanged()...

    */

    @Override

    protected void onPostCreate(Bundle savedInstanceState) {


    Download 0,86 Mb.

    Do'stlaringiz bilan baham:
1   2   3   4   5   6   7




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish