开发者

Whenever I run this code It crashes in the android Emulator

I consistantly get an error when I run this line

moreContent.addView(findViewById(moreViews[0]), 0);
extr开发者_如何学Goa code:
private int[] moreViews={
    0x7f060006, 0x7f060007, 0x7f060009, 0x7f06000a, 0x7f06000b
};


Use R.layout. rather than its actual id.


You should not reference the ids by the hex number, but using R.id.xxx.

Without the logcat is impossible to tell, but most probably there is no resource found.


Don't use the raw resource values. They will change when AAPT generates new ones. Use the constants defined in R.java. This is terrible programming practice. Make use of the constants!

private int[] moreView = {R.id.myView1, R.id.myView2, ...};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜