如果我知道视图的名称,获取字符串的资源名称

时间:2014-08-22 00:07:02

标签: android android-resources

我有一个TextView

 <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:text="@string/str_text"
        android:textAppearance="?android:attr/textAppearanceMedium" />

如果我有这个......

TextView txt = (TextView) getView().findViewById(R.id.textView1);

我怎样才能得到这个

"str_text"

1 个答案:

答案 0 :(得分:1)

你不能。你可以从ID到值,但不是相反。为了更清楚地说明原因,请假设您有多个具有相同值的字符串资源。

在对视图进行充气后,不会存储资源ID。

相关问题