How to read icon / image name set for menu item in android

202 Views Asked by At
<item
        android:title="bookmark"
        android:icon="@drawable/ic_baseline_bookmark_border"
        android:id="@+id/bookmark"
        app:showAsAction="ifRoom"/>

Hi, in the above code I am showing a bookmark icon in a menu item but now my requirement is to read the icon name, I am able to read or get the id of this item by using the below code

@Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        int res_id=item.getItemId();
}

but I am not able to get the icon name

please help !! thanks in advance

1

There are 1 best solutions below

0
On

please refer this article for getting more information while referring this question

https://android.i-visionblog.com/android-changing-menu-items-at-run-time-48970f0cf1b7

all thanks to Ramkumar N