TextView tv = new TextView(this);
tv.setId(1);
ListView lView = new ListView(this);
String[] lStr = new String[] { "A", "B", "C" };
ArrayAdapter<String> lAdap = new ArrayAdapter<String>(this, tv.getId(), lStr);
lView.setAdapter(lAdap);
setContentView(lView);
錯誤:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.dtl/com.example.dtl.MainActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x2
感謝工作:) – vhong 2012-07-23 02:18:40