Android,如何传递视图和视图组参数
我想更改列表视图中的一个视图的背景颜色
myListView.getView(intposition, View ConvertView, ViewGroupparent).setBackgroundColor(0x00FFE303);
我知道位置是什么 - 这将是我的数组适配器的索引,但我不知道视图和视图组是什么。我已经在这一行上方声明了它们,但我不知道如何初始化它们以
提供帮助?
I want to change the background color of one of my views in my listview
myListView.getView(int position, View convertView, ViewGroup parent).setBackgroundColor(0x00FFE303);
I know what position is - this will be my index of the arrayadapter, but I don't know what view and viewgroup are. I have declared them above this line, but I don't know what to initialize them to
help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定您想像这样手动调用 getView() 。当列表视图中的项目绘制到屏幕上时,Android 会自动调用 getView。最常见的做法是扩展 Adapter 类(如 ArrayAdapter)并 @Override getView() 方法。
I'm not sure you want to be calling getView() manually like that. getView is called automatically by Android when a item in a listview is drawn to the screen. What would be most common to do, would be to extend an Adapter class (like ArrayAdapter) and @Override the getView() method.