Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个view并且我有它的资源 ID(即R.id.xxx),我想提取该xxx部分并将其转换为字符串。
view
R.id.xxx
xxx
那有可能吗?
为了清楚起见,我有view.getId() 一个资源整数,而不是 id 的实际名称。
view.getId()
View v; String ResourceIdAsString = v.getResources().getResourceName(v.getId());
在视图构造函数中使用 this
您可以使用
getResources().getResourceEntryName(int resid);