我有大問題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