关于linearLayout 的setId()方法,,

sll_docking 2011-08-17 09:29:44
logoLinear1 = new LinearLayout(this);
logoLinear1.setLayoutParams(new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
logoLinear1.setOrientation(LinearLayout.VERTICAL);
logoLinear1.setId(111);

textView = new TextView(this);
textView.setLayoutParams(new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
logoLinear1.addView(textView);

adapter = new ArrayAdapter<String>(this,logoLinear1.getId(),strs);


08-17 01:31:08.695: ERROR/AndroidRuntime(559): android.content.res.Resources$NotFoundException: Resource ID #0x6f


这是为什么呢,,
...全文
436 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hijovi 2011-08-17
  • 打赏
  • 举报
回复
logoLinear1.getId()
这个id他根本在R.java找不到

他的实现里
view = mInflater.inflate(resource, parent, false);
看看
文档描述LayoutInflater的作用
This class is used to instantiate layout XML file into its corresponding View objects

明白了吧
sll_docking 2011-08-17
  • 打赏
  • 举报
回复
其实我是不想用xml添加布局,所以这样想的,,不过我还是没有实现,,
logoLinear1.getId()
这个id他根本在R.java找不到
的确是这样,,
那要是我要使用ArrayAdapter 且又不使用xml,添加布局,,那ArrayAdapter(this,R.layout.main,strs);

R.layout.main这个能不能用自己写的布局替换掉呢,,提个好的方法。

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧