Hello everyone,
I got the problem when create menu. The icon of the menu didn't appear. The size icon is 36x36.
import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.widget.Toast; public class AppAndrActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.layout.menu, menu); return true; } /** * Event Handling for Individual menu item selected * Identify single menu item by it's id * */ @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_bookmark: // Single menu item is selected do something // Ex: launching new activity/screen or show alert message Toast.makeText(AppAndrActivity.this, "Bookmark is Selected", Toast.LENGTH_SHORT).show(); return true; case R.id.menu_save: Toast.makeText(AppAndrActivity.this, "Save is Selected", Toast.LENGTH_SHORT).show(); return true; case R.id.menu_search: Toast.makeText(AppAndrActivity.this, "Search is Selected", Toast.LENGTH_SHORT).show(); return true; case R.id.menu_share: Toast.makeText(AppAndrActivity.this, "Share is Selected", Toast.LENGTH_SHORT).show(); return true; case R.id.menu_delete: Toast.makeText(AppAndrActivity.this, "Delete is Selected", Toast.LENGTH_SHORT).show(); return true; case R.id.menu_preferences: Toast.makeText(AppAndrActivity.this, "Preferences is Selected", Toast.LENGTH_SHORT).show(); return true; default: return super.onOptionsItemSelected(item); } } }
And this is my xml file, menu.xml
<?xml version="1.0" encoding="UTF-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Single menu item Set id, icon and Title for each menu item --> <item android:id="@+id/menu_bookmark" android:icon="@drawable/icon_bookmark2" android:title="Bookmark" /> <item android:id="@+id/menu_save" android:icon="@drawable/icon_save2" android:title="Save" /> <item android:id="@+id/menu_search" android:icon="@drawable/icon_search2" android:title="Search" /> <item android:id="@+id/menu_share" android:icon="@drawable/icon_share2" android:title="Share" /> <item android:id="@+id/menu_delete" android:icon="@drawable/icon_delete2" android:title="Delete" /> <item android:id="@+id/menu_preferences" android:icon="@drawable/icon_preferences2" android:title="Preferences" /> </menu>
This is my AVD properties;
- TargetName : Android 4.0.3
- Platform : 4.0.3
- API Level : 15.0
Doesn't anyone know what is my fouls ?