这应该很简单,但是会让我疯狂。从数组中保存的字符串资源设置textview文本
我在布局中有以下,而不是问题。
<TextView
android:id="@+id/birdinfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#00009c"
android:text="The Robin is a popular bird"
/>
然后我有设置了字符串资源的列表,这些阵列我有
private Integer[] DetailIds = {
R.string.barnaclegoose,
R.string.barnowl,
R.string.bewicksswan,
R.string.blackbird,
R.string.blackcap_male};
所以我只是想做到这一点!
TextView detail = (TextView)findViewById(R.id.birdinfo);
detail.setText(DetailIds[0]);
setContentView(R.layout.main);
但是这会导致强制关闭错误。
字符串资源看起来是这样的(当然没有页眉和页脚信息
<string name="barnaclegoose">What a wonderful goose!</string>
添加到这个问题,如果我直接使用资源到资源
detail.setText(R.string.barnaclegoose);
例如,我仍然得到一个零例外!我确信我以前做过这个,但也许我错过了明显???
任何想法赞赏。
(Eclipse,Android 1.5,Emulator with 1.5)
你确定,你可以在整型内举行的字符串阵列? ;-) – poeschlorn 2010-06-29 11:15:55
发布表示的堆栈跟踪 – Budius 2016-06-25 09:10:00