I want icons on action bar, but I am getting them in the menu options... Here is my xml
<menu xmlns:android="http://ift.tt/nIICcg"
xmlns:app="http://ift.tt/GEGVYd">
<item
android:id="@+id/share"
android:orderInCategory="100"
android:title="Share on Whatsapp"
app:showAsAction="always"/>
<item
android:id="@+id/medication"
android:title="My Medications"
android:icon="@drawable/medication"
app:showAsAction="always"/>
<item
android:id="@+id/coc"
android:title="Add Circle of care"
android:icon="@drawable/add_icon"
app:showAsAction="always"/>
<item
android:id="@+id/report"
android:title="Report"
android:icon="@drawable/report"
app:showAsAction="always"/>
</menu>
and here is the 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.dashboard, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == android.R.id.home) {
menu.toggle(true);
return true;
}
if(id==R.id.coc){
startActivity(new Intent(Dashboard.this,CircleOfCare.class));
}
return super.onOptionsItemSelected(item);
}
What am I missing.. I am extending Activity.. If I extend ActionBarActivity, it says, use theme.appcompat or descendant even when I am using that theme only. Please help, thanx in advance
Aucun commentaire:
Enregistrer un commentaire