繁体   English   中英

滚动后的画廊位置

[英]Gallery Position After scrolling

我有一个包含7张图片的画廊。 停止Gallery时如何获得位置?

作为参考,您可以处理Galley组件的setOnItemSelectedListener来执行此操作。

    // 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

        }
        //>
    });
    //-->

您是否在图库中使用适配器? 如果是这样,则AdapterView具有返回一个int的getSelectedItemPosition()函数。

您可以子类化ImageAdapter类,并添加一个返回私有int的函数,该int始终更新为最后一个“单击”图像的索引; 从而为您提供当前图像的位置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM