2017年11月11日 星期六

Android Studio:Activity上方Menu選單製作

New/Android resource file產生一備資源檔。


其Reource type定義為「Menu」,再輸入檔名為menu_main.xml。


其實選單位置在res/menu/menu_main.xml。



於menu_main.xml中加入item元素,並設定android:id、android:title、app:showAsAction三屬性。


app:showAsAction為其在ToolBar上顯示之原則,其屬性有:
  • never:不會顯示
  • ifRoom:有空間就顯示
  • always:都顯示
  • withText:除icon圖示外,也顯示item的標題文字
android:orderInCategory為整數,菜單項目順序,數字越小的越前面

Related Posts:

  • Android Studio:Activity上方Menu選單製作!-- 實作Activity上方選單Menu與下拉項目功能 https://litotom.com/2017/07/31/ch7-4-menu/ 選單 https://developer.android.com/guide/topics/ui/menus.html Android SDK 超級初學者筆記 (2) - Menu & Activity 資訊傳遞 http://sweeteason.pixnet.net/blog/post/3370… Read More
  • Android Studio:finish()、onDestory()、System.exit(0)的區別!-- Android Activity类中的finish()、onDestory()和System.exit(0) 三者的区别 http://blog.csdn.net/yelangjueqi/article/details/9466347 -- Activity.finish():將Activity移出線,其還占用資源沒有被釋放,所以按手機"back"按鍵的時候,也找不到這個Activity。 Activity.onDestory():為… Read More
  • Android Studio:退出/刪除活動頁(Activity)。!-- 如何殺死一個Android的活動,當離開它,以便它不能從後退按鈕訪問? https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-TW&prev=search&rurl=translate.google.com.tw&sl=en&sp=nmt4&u=https://stackoverflow.com/questions/2550099/how-to-kill-an… Read More
  • Android Studio:什麼是 Views?!-- UI輸入事件 https://developer.android.com/guide/topics/ui/ui-events.html?hl=zh-tw Jollen 的Android 教學,#1: Android 應用程式模式 http://www.jollen.org/blog/2008/12/jollen-android-programming-1.html Jollen 的 Android 教學,#15: 什麼是事件監聽器(… Read More
  • Android Studio:將專案匯出為 APK及匯出位置!-- 如何安裝APK檔 https://www.youtube.com/watch?v=GdXvSJx9B2Y Android Studio - 將專案匯出為 APK http://kanchengzxdfgcv.blogspot.tw/2017/12/android-studio-apk.html [AndroidStudio] 建立Signed APK 檔上架至Google Play ... https://disp.cc/b/1… Read More

0 意見:

張貼留言