开发者

Android CustomHow to get Child Views from Custom ListView enclosed within linearlayout without clicking listview

开发者 https://www.devze.com 2023-02-22 22:10 出处:网络
I have a custom listview with two buttons and two textViews enclosed within linearlayout. I want to iterate through the listView without clicking the listView rows. When i do

I have a custom listview with two buttons and two textViews enclosed within linearlayout. I want to iterate through the listView without clicking the listView rows. When i do listView.getChildAt(position); position can be any integer from 0 onwards it gives null output, what is the other way to开发者_JS百科 get views from listView. Please help.


There isn't really an interface exposed for getting the view objects from a ListView. These are constantly being switched out and stored for recycling as rows scroll in and out of the visible area.

However, you can do:

listView.getItemAtPosition(position);

to get the model (item) at a given position in the list. If you need to operate on information that the user changes in your list, then you would want to first save that information back to the underlying model individually when each component changes and then later aggregate over your underlying data objects to do your calculation.

0

精彩评论

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