点击获取项目的索引,在ListView [英] getting the index of clicked item in a listview

查看:91
本文介绍了点击获取项目的索引,在ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得所选择的项目(点击)的指数在ListView。

I want to get the index of the Selected Item ( Clicked ) in a ListView.

任何一个可以告诉我?

谢谢 迪帕克

推荐答案

您需要使用适配器视图及其onItemClick方法:

You need to use an AdapterView and its onItemClick method :

lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    public void onItemClick(AdapterView<?> list, View v, int pos, long id) {
        yourAdapter.getItem(pos);           
    }
});

这篇关于点击获取项目的索引,在ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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