I have tried everything that i could have. gone through 6-7 articles except http://developer.android.com/
and things totally messed up i don't know what i am missing or taking the reference of wrong articles.
Here is my code:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/userIcon"
android:orderInCategory="100"
android:showAsAction="always"
android:icon="@drawable/icon_user"
android:title="@string/app_name"/>
<item
android:id="@+id/listIcon"
android:orderInCategory="100"
android:showAsAction="always"
android:icon="@drawable/icon_list"
android:title="@string/app_name"/>
<item
android:id="@+id/menu_red"
android:orderInCategory="1"
android:showAsAction="ifRoom|withText"
android:title="@string/get_back"/>
<item
android:id="@+id/menu_green"
android:orderInCategory="2"
android:showAsAction="ifRoom|withText"
android:title="@string/get_login"/>
</menu>
Activity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_product_list, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case R.id.listIcon:
Toast.makeText(this,
"Menu list",
Toast.LENGTH_LONG).show();
break;
case R.id.userIcon:
Toast.makeText(this,
"User Icon",
Toast.LENGTH_LONG).show();
break;
}
//return super.onOptionsItemSelected(item);
return true;
}