I have a gallery with 7 images.
How can I get the positi开发者_StackOverflow社区on when stop the scrolling of a Gallery?
For reference you can handle the setOnItemSelectedListenerof the Galley component to do this.
    // Gallery On Item Selected
    mGallery.setOnItemSelectedListener(new OnItemSelectedListener() {
        // On Item Selected
        public void onItemSelected(CustomAdapterView<?> parent, View view,
                int position, long id) {
            // Do some custom action here!
        }
        //>
        // On Nothing Selected
        public void onNothingSelected(CustomAdapterView<?> parent) {
            // TODO Auto-generated method stub
        }
        //>
    });
    //-->
Are you using an Adapter with the Gallery? If so, then AdapterView has a getSelectedItemPosition() function that returns an int.
You can subclass the ImageAdapter class and add a function that returns a private int which is always updated to the index of the last 'clicked' image; thus giving you the position of the current image.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论