Android - ListView - performItemClick [英] Android - ListView - performItemClick

查看:30
本文介绍了Android - ListView - performItemClick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试使用 ListView 的 performItemClick 函数时遇到了一些困难.

I'm facing some difficults when I try to use the performItemClick funcion of the ListView.

我想要做的就是在列表的第一项中以编程方式执行一次点击.

All I want to do is to perform a click programatically in the first item of the list.

我该怎么做?我在文档中查找了那个函​​数,但我并没有真正理解它的参数.

How can I do that? I looked up that function in the documentation, but I didn't really understand its parameters.

我尝试了类似的东西:

 myListView.performItemClick(myListView.getChildAt(0), 0, myListView.getChildAt(0).getId());

但是它没有用 (myListView.getChildAt(0) 返回 null)

先谢谢你!

推荐答案

mList.performItemClick(
        mList.getAdapter().getView(mActivePosition, null, null),
        mActivePosition,
        mList.getAdapter().getItemId(mActivePosition));

其中 mActivePosition 是您的点击位置!一切顺利!:)

Where mActivePosition is your click position! All the best! :)

这篇关于Android - ListView - performItemClick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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