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



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

Xml code example

app:showAsAction="ifRoom"

android:title="@string/action_settings"/>

android:title="sub menu"

app:showAsAction="always" >

android:orderInCategory="1"

android:title="subitem1"/>

android:orderInCategory="2"

android:title="subitem2"/>

android:title="item1"/>

android:title="item2"/>


Show if room, if not show in normal
menu
Always shows and creates a
Drop menu (separate from standard
Menu)
Normal menu items

End result

  • This shows how it can look
    • The sub menu item has been clicked to show the sub menu.

Action Bar

  • We can also have “buttons” as well and change them as needed, programmatically.
  • This example uses the ViewPager fragment example and adds buttons for Previous and Next
    • also finish, but that doesn’t do anything
  • The buttons may show at the bottom of the screen if there is not enough space on the actionbar.

Java code

  • We need to use the invalidateOptionsMenu(); every time the page is changed, so
    • Using the ViewPager.setOnPageChangeListener(…)
  • Otherwise the main work is in the onCreateOptionsMenu(Menu menu)

OnCreateOptionsMenu

public boolean onCreateOptionsMenu(Menu menu) {

super.onCreateOptionsMenu(menu);

getMenuInflater().inflate(R.menu.activity_screen_slide, menu);

  • Enable the previous menu item, if we are not on the first page (xml).
  • menu.findItem(R.id.action_previous).setEnabled(viewPager.getCurrentItem() > 0);
  • Add either a "next" or "finish" button to the action bar, depending on which page is currently selected. Done programmatically.

  • 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