点击的ImageView内的ListView列表项,并获得了位置? [英] Click ImageView within a ListView ListItem and get the position?

查看:204
本文介绍了点击的ImageView内的ListView列表项,并获得了位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,该列表项被点击时,我抓住它的位置,并把它传递给我的StopsScheduleActiviy。我想检测的ListItem的ImageView的被点击的时候,这样我可以启动我MapActivity代替,并通过它的位置。

Currently, when the ListItem is clicked I grab its position and pass it to my StopsScheduleActiviy. I would like to detect when the ImageView of that ListItem is clicked so that I can launch my MapActivity instead and pass it the position.

基本上是:点击ImageView的推出MapsActivity,否则单击其他任何地方的ListItem推出StopsScheduleActivity。在这两种情况下,我需要的位置。我怎样才能做到这一点?

Basically: Click the ImageView launch MapsActivity, otherwise click anywhere else on ListItem launch StopsScheduleActivity. In Both cases I need the position. How can I do this?

下面是我目前的onItemClick听众。

Here is my current onItemClick listener.

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    Intent myIntent = new Intent(this, StopsScheduleActivity.class);
    myIntent.putExtra("stop", stops.get(position));

    startActivity(myIntent);

    Log.i("Winnipeg Bus", "Stop item #" + id + " clicked.");
}

下面是我的ListView一个地图,我要听的点击一个ImageView的。谢谢!

Here is my ListView with a map for an ImageView that I want to listen to for clicks. Thanks!

推荐答案

对于的ImageView点击您要为您的列表视图自定义适配器

而在adpater的 getView()方法只写了的ImageView的onClick(),而从开始的新活动该ImageView的的onClick()。

And in adpater's getView() method just write a imageView's onClick(), And start your new activity from that imageview's onClick().

有关自定义列表单看本教程的Andr​​oid系列:自定义的ListView项目和适配器 ..

For custom list just look at this tutorial Android Series: Custom ListView items and adapters ..

这篇关于点击的ImageView内的ListView列表项,并获得了位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆