我的 XML 中有以下元素
<EditText
android:id="@+id/kernelb11"
android:layout_width="@dimen/matrixBoxWidthHeight"
android:layout_height="@dimen/matrixBoxWidthHeight"
android:layout_below="@+id/textViewb"
android:layout_margin="@dimen/marginOne"
android:background="@color/white1"
android:gravity="center"
android:inputType="numberSigned"
android:maxLength="2"
android:text="5" >
<requestFocus />
</EditText>
我试图在代码中检索它的价值,例如:
String name = "kernelb11";
int a = this.getResources().getIdentifier(name, null, null); //
String as = (String) this.getResources().getText(a);
但是在getIdentifier
返回我只是'0'谁能告诉我为什么?