开发者

Gallery Position After scrolling

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜