开发者

Android, how to pass view and viewgroup parameters

开发者 https://www.devze.com 2023-03-17 05:34 出处:网络
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 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?


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.

0

精彩评论

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