0

I want to show notification counter like this

https://i.stack.imgur.com/TlsFf.jpg

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 enter image description here

What I want
enter image description here

How can I solve this problem? Thank you in advance!!

Pandarian Ld
  • 727
  • 3
  • 13
  • 25

1 Answers1

1

You need Custom View List using RecycleView which has one icon,text and the number textview as per your requirement

Here is on Example

You can refer this example

Burhanuddin Rashid
  • 5,260
  • 6
  • 34
  • 51