public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.Friends: // TODO break;
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/friends" android:title="Friends" android:icon="@drawable/friends" > </item> <item android:id="@+id/events" android:title="Events" android:icon="@drawable/events" > </item> <item android:id="@+id/Profile" android:title="Profile" android:icon="@drawable/profile" > </item> <item android:id="@+id/Close" android:title="Close" android:icon="@drawable/close" > </item> </menu>
package com.example.helloandroid; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; public class HelloAndroid 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 inflater = getMenuInflater(); inflater.inflate(R.menu.app_menu, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.Friends: // TODO break; case R.id.Events: // TODO break; case R.id.Profile: // TODO break; case R.id.Close: // TODO break; default: return super.onOptionsItemSelected(item); } return true; } }
R.id
R.id.Friends
R.id.friends
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)