我有一个导航菜单 它里面有很多元素 每个元素都有一个图标 我要做的就是放一个显示某些内容的图标。 而且我可以通过显示或消失来控制此图标。 但是现在对我来说重要的是制作一个图标,就像您面前这张照片中的图标一样。 picture //
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:checked="true"
android:id="@+id/zero"
android:title="@string/all"
android:icon="@drawable/staremptys">
</item>
<item
android:id="@+id/one"
android:title="@string/favourite"
android:icon="@drawable/starfilleds">
</item>
<item
android:id="@+id/two"
android:title="@string/facebookPage"
android:icon="@drawable/facebook">
</item>
<item
android:id="@+id/four"
android:title="دوريات وبطولات"
android:icon="@drawable/champion">
</item>
<item
android:id="@+id/three"
android:title="@string/callUs"
android:icon="@drawable/ic_call_black_24dp">
</item>
</group>
</menu>
// code java in mainactivity :
nav.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
menuItem.setChecked(true);
// close drawer when item is tapped
_DrawerLayout.closeDrawers();
switch (menuItem.getItemId()) {
case R.id.zero:
searchList = stadiumList;
upDateList(searchList);
fav = false;
break;
case R.id.one:
Log.i("traceVal:: ","one");
searchList = getFavList();
upDateList(searchList);
break;
case R.id.two:
Log.i("traceVal:: ","two");
Intent facebookIntent = new Intent(Intent.ACTION_VIEW);
String facebookUrl = getFacebookPageURL(getBaseContext());
facebookIntent.setData(Uri.parse(facebookUrl));
startActivity(facebookIntent);
break;
case R.id.three:
Log.i("traceVal:: ","three");
call2("01069988589");
break;
case R.id.four:
Intent myIntent = new Intent(getBaseContext(),teamsnews.class);
startActivity(myIntent);
//Log.i("traceVal:: ","two");
break;
}
return true;
}
});
}