Reputation: 369
Has anyone ever put a page indicator at the top of a gallery? Writing your own gallery and overriding onScroll() doesn't cut it because it only updates while the user scrolls (it stops being called while fling inertia and snapping occurs).
It would be nice if there was an easy way of intercepting all gallery motion, but I haven't seen a way to do this.
Thanks in advance!
Upvotes: 1
Views: 6426
Reputation: 369
As it turns out, it's as easy as adding an OnItemSelectedListener().
gallery.setOnItemSelectedListener(new OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) {
guiText.setText((position+1)+" of "+adapter.getCount());
}
@Override
public void onNothingSelected(AdapterView<?> adapter) {
guiText.setText("");
}
});
Upvotes: 7
Reputation: 129812
I think Jon O's patch on Eric Taix excellent Workspace View, as can be found here, does an excellent job of rolling a custom gallery with a page indicator.
Upvotes: 0