How to get Resource Name from Resource id

In your Activity, try these:

  1. to get string like radio1:

    getResources().getResourceEntryName(int resid);
    
  2. to get string like com.sample.app:id/radio1:

    getResources().getResourceName(int resid);
    

In Kotlin Now :

val name = v.context.resources.getResourceEntryName(v.id)

You have id('long' type) from that id you want to access radio button id(name) that is radio1. You use this

getResources().getResourceEntryName(id);

in using above you can get name of radio button i.e. radio1. here parameter id is which you have(long type). Try this it will helps you 100%.

Tags:

Android