how to know from adapter if the item of ListView is visible or not?

不问归期 提交于 2020-01-01 08:06:52

问题


I have an adapter that connected to ListView, e.g.

mJournalAdapter = new JournalAdapter();
journalEntryList.setAdapter(mJournalAdapter);

and I want to know inside of my JournalAdapter if some view (item of ListView) is visible or not, is it possible?


回答1:


If you know the postion of that item then you can use

int last = listView1.getLastVisiblePosition();  

int first = listView1.getFirstVisiblePosition();



回答2:


You can get callback , overriding OnDetachedFromWindow(); method in View




回答3:


You can use getFirstVisiblePosition() will give you the first visible Item in the ListView, so you can use that in your case.



来源:https://stackoverflow.com/questions/11152432/how-to-know-from-adapter-if-the-item-of-listview-is-visible-or-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!