Study Notes for Android beginners-menu 1
Mainactivity. java start to load 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;}
Configure the menu in main. xml under menu under res
Android: orderInCatagory menu sorting
Android: id index primary key
Android: title menu name
Menu RESPONSE event
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);}
You can use the sibling cloud class to learn the menu setting process, as well as the custom icons for menus earlier than 2.3, and disable this function after 2.3.
At this stage, I feel a little confused about many calling methods.