Android入門學習筆記之-菜單一,android入門學習筆記

來源:互聯網
上載者:User

Android入門學習筆記之-菜單一,android入門學習筆記

Mainactivity.java   啟動載入menu

@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}


在res下 menu 下的 main.xml 來配置菜單


 <item        android:id="@+id/lidl"        android:orderInCategory="100"          android:title="@string/action_settings" />    <item        android:id="@+id/end"        android:orderInCategory="200"          android:title="@string/end" />
android:orderInCatagory  菜單排序

android:id  索引主鍵

android:title   菜單名稱


菜單響應事件

public boolean onOptionsItemSelected(MenuItem item){switch(item.getItemId()){case R.id.lidl:Toast.makeText(this, "t1", Toast.LENGTH_SHORT).show();break;case R.id.end:Toast.makeText(this, "t2", Toast.LENGTH_SHORT).show();break;}return super.onOptionsItemSelected(item);}

通過兄弟連雲課堂,知道菜單設定的流程,以及2.3之前 菜單可以自訂表徵圖,2.3以後取消該功能


現階段,對很多調用的方法感覺有點蒙


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.