我是新來的Android(和肯定我不是專家Java開發人員),所以我的愚蠢的問題抱歉動態字符串和XML
我想「捕獲」的ID TextView的和動態設置它的文本值, 這裏是我怎樣,我想這樣做:
public class AndStringTestActivity extends Activity {
/** Called when the activity is first created. */
String abc = "abcabc";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = (TextView)findViewById(R.id.test);
tv.setText(abc);
setContentView(R.layout.main);
}
}
,這裏是我從中讀的TextView的id我想裏面寫的Xml
// main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/test"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
我收到的錯誤是通常的Application stopped unexpectedly
謝謝。