如何获得资源名称的资源ID [英] How to get Resource Name from Resource id
本文介绍了如何获得资源名称的资源ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的布局我已经定义了这样的事情。
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" />
假设在活动的一些函数返回我这个ID(单选按钮的ID)。现在,我想这个文本的收音机1 此ID。
总之我想要检索的文本收音机1 写在机器人:ID =@ + ID /收音机1
有谁能告诉我,怎么可能?
Can somebody tell me how is it possible ?
推荐答案
在你的活动,请尝试以下
In your Activity, try the following
getResources()getResourceEntryName(INT渣油);
getResources().getResourceEntryName(int resid);
或
getResources()getResourceName(INT渣油);
getResources().getResourceName(int resid);
您将preFER第一个我想。
You'll prefer the first one I guess.
这篇关于如何获得资源名称的资源ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文