how to know from adapter if the item of ListView i

2019-04-05 01:28发布

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?

3条回答
萌系小妹纸
2楼-- · 2019-04-05 02:02

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

int last = listView1.getLastVisiblePosition();  

int first = listView1.getFirstVisiblePosition();
查看更多
祖国的老花朵
3楼-- · 2019-04-05 02:08

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

查看更多
仙女界的扛把子
4楼-- · 2019-04-05 02:11

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

查看更多
登录 后发表回答