Search code examples
androidandroid-layouttextviewgalleryonfling

Override Views that OnFling hasn't Shown Yet


Is there a way I can get a reference to the Views that onFling has not yet revealed? I'm extending Gallery, and in my onFling method, of course I can get the current View (the one that is showing already). But I haven't found a way to get the views that are about to be flung by. I need to change properties like backgroundColor (it's a Gallery of TextViews).


Solution

  • There's a nifty method for handling each onFocus event in a gallery fling. As each item comes into focus, this will get fired.

    thisGallery.setOnItemSelectedListener(new OnItemSelectedListener() {
       @Override
       public void onItemSelected(AdapterView<?> parentView,
                                  View selectedItemView,
                                  int position,
                                  long id) { }