How to get Resource Name from Resource id

android

Solution

In your Activity, try these:

to get string like `radio1`:

getResources().getResourceEntryName(int resid);

to get string like `com.sample.app:id/radio1`:

getResources().getResourceName(int resid);

In Kotlin Now :

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

Problem

In my layout I have defined something like this . ``` <RadioButton android:id="@+id/radio1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Dnt want this text" /> ``` Assume that some function in activity returns me this id (id of radioButton). Now i want to get this text radio1 from this id. In short I want to retrieve text radio1 written in `android:id="@+id/radio1"` Can somebody tell me how is it possible ?

Original source