I hope I understand your question. if yes, then here is the idea:
you need to keep a private instance variable that keeps track of the current position of the image displayed from the cover stream. then you update it using the setOnItemSelectedListener() method, which is inherited from Gallery. On the back or forward button, you simply set your current selection +/- 1 depending on the button you pressed.
so in your Activity add an int instance variable that will track the position as ...
public class MyActivity { private int currentImagePosition = -1;
Then you will need to update the current position of the image, which is currently displayed in the cover stream. you can do this by overriding setOnItemSelectedListener like this (inside your onCreate method):
coverFlow.setOnItemSelectedListener(new OnItemSelectedListener(){ @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { currentImagePosition = position;
Finally, all you have to do is set each onclick listeners button to go to the previous or next image using setSelection( currentImagePosition+1 ) or setSelection( currentImagePosition-1 ) . By the way, what does the true or false setSelection() parameter setSelection() ? I'm not sure what it does, so I just use true , as you did initially. your onCreate() method will now look something like this:
@Override public void onCreate(Bundle savedInstanceState){
NOTE. It is assumed that the part on the update position works from reading Get the position of the current image displayed in the Gallery , so I hope this works. if not, at least I tried: D
Good luck !!!
David T.
source share