olegflo
olegflo

Reputation: 1115

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

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?

Upvotes: 14

Views: 13298

Answers (3)

Dheeresh Singh
Dheeresh Singh

Reputation: 15701

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

int last = listView1.getLastVisiblePosition();  

int first = listView1.getFirstVisiblePosition();

Upvotes: 24

dooplaye
dooplaye

Reputation: 1029

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

Upvotes: 6

Lalit Poptani
Lalit Poptani

Reputation: 67286

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

Upvotes: 2

Related Questions