I want to show notification counter like this
But instead of a counter on NavigationView
as shown in the image, I want it to shown in PopupMenu
at pending_req item
Here is menu_project.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<group>
<item
android:id="@+id/detail"
android:title="@string/detail" />
<item
android:id="@+id/pending_req"
app:actionViewClass="android.widget.TextView"
android:title="@string/pending_request"
app:showAsAction="always"/>
</group>
</menu>
Here is a method to show PopupMenu
private void showProjectMenu(View v) {
PopupMenu popupMenu = new PopupMenu(this, v);
popupMenu.getMenuInflater().inflate(R.menu.menu_project, popupMenu.getMenu());
TextView pendReqN = (TextView)popupMenu.getMenu().findItem(R.id.pending_req).getActionView();
pendReqN.setText("3");
popupMenu.show();
}
EDIT:
And this is the result when click item 00004
How can I solve this problem? Thank you in advance!!