如何获取图像库中哪张图像(其位置)处于焦点?

发布于 2024-08-31 17:42:30 字数 169 浏览 7 评论 0原文

我正在摆弄图库小部件。

我想知道如何才能获得图库中焦点图像的位置。

例如,我的画廊中有几张图片,如果我向右轻按手指,图片就会来来去去,直到停在一张为止。

如何获得当前对焦的这张图片的位置?

不知道我说得够不够清楚,如果有什么需要我补充的,请不要犹豫。 谢谢你,

I am playing around with the Gallery widget.

I would like to know how can we get the position of the image on focus in the gallery.

For example having several pictures in my gallery, if I tap my finger to the right, pictures will come and go until it stop to one.

How one can get the position of this one picture that is currently on focus ?

I don't know if I was clear enough, if there is anything you want me to add do not hesitate.
Thank you,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

度的依靠╰つ 2024-09-07 17:42:30

在 Gallery Widget 上设置一个 OnItemSelectedListener,覆盖适当的方法 [我认为回调名为 onItemSelected(...)]。焦点项目的位置将作为参数传递给此回调函数。

伪代码:

Gallery g = (Gallery) findViewById(R.id.gallery);
//set Adapter with appropriate data model
g.setOnItemSelectedListener(this);

public void onItemSelected(AdapterView parent, View v, int position, long id) {
//position is item having focus
}

希望有帮助......

Set an OnItemSelectedListener on the Gallery Widget, override appropriate method [I think the callback is named onItemSelected(...)]. The position of item in focus would be passed as argument to this callback function.

Pseudo code:

Gallery g = (Gallery) findViewById(R.id.gallery);
//set Adapter with appropriate data model
g.setOnItemSelectedListener(this);

public void onItemSelected(AdapterView parent, View v, int position, long id) {
//position is item having focus
}

Hope that helps...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文