我正在尝试从代码中更改我的TextView
文本。
这是我的xml的样子:
XML:
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal" />
代码如下:
TextView tv1 = (TextView)findViewById(R.id.textView1);
tv1.setText("Hello");
setContentView(tv1);
我的设备出现了错误,并且应用程序停止了。我尝试展示一个 TextView
(未连接到 XML 的 TextView
),它可以工作。