我有大问题inflate
累了。android充气视图findViewById不工作
我在我的应用程序的另一个布局,这是message
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="369dp"
android:text="New Text"
android:id="@+id/msg"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button2"/>
</LinearLayout>
,当我试图改变msg
文本它的失败:
View vw = getLayoutInflater().inflate(R.layout.message, null);
msg = (TextView) vw.findViewById(R.id.msg);
msg.setText("123");
setContentView(R.layout.message);
和应用程序也不例外。
我该如何解决它?
好极了,还有Tnx。 – 2014-11-23 08:43:29