ListView控件与OnItemClickListener机器人 [英] ListView with OnItemClickListener android

查看:96
本文介绍了ListView控件与OnItemClickListener机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是自定义的的ListView 用的RatingBar和ImageButton的。这里是我的问题:当我点击我的ListView,我OnItemClickListener不工作。请任何一个可以帮助我。 code:

I am using a custom ListView with RatingBar and ImageButton. Here is my problem: When I click on my ListView, my OnItemClickListener is not working. Please can any one help me. Code:

ListView lv = getListView();
setContentView(lv);
lv.setOnItemClickListener(new OnItemClickListener()
{
    @Override 
    public void onItemClick(AdapterView<?> arg0, View arg1,int position, long arg3)
    { 
        Toast.makeText(SuggestionActivity.this, "" + position, Toast.LENGTH_SHORT).show();
    }
});

在此先感谢!

Thanks in advance!

推荐答案

虽然一个非常古老的问题,但我仍然张贴的答案,这使得它可以帮助一些之一。 如果您正在使用的列表视图中的任何布局,然后使用...

Though a very old question, but I am still posting an answer to it so that it may help some one. If you are using any layout inside the list view then use ...

android:descendantFocusability="blocksDescendants"    

...就行了里面的第一个父布局。这可以作为魔术的点击不会被列表中的任何元素被消耗掉,但将直接进入该列表项。

... on the first parent layout inside the list. This works as magic the click will not be consumed by any element inside the list but will directly go to the list item.

这篇关于ListView控件与OnItemClickListener机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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