点击不工作的列表项列表视图的android [英] Click is not working on the Listitem Listview android

查看:138
本文介绍了点击不工作的列表项列表视图的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现了android 列表视图 ListActivity 。在这里,我有问题,当我点击时,闪光灯的颜色也不会来是橙色不执行任何操作的列表项。所以,你对这个好心回答我的问题的想法。

I implemented the android listview with the ListActivity. Here I have the problem that when i click on the list item no action is performed when the flash color is also not coming that is the orange color. So do you have any idea about this kindly answer to my question.

@Override
protected void onListItemClick(ListView l, View v, int position, long id) 
{
    super.onListItemClick(l, v, position, id);
    Toast.makeText(getApplicationContext(), "msg msg", Toast.LENGTH_SHORT)
            .show();

}

我把这个code也进入主ListActivity。

I put this code also into the Main ListActivity.

推荐答案

你有什么要注意的第一件事是,当有喜欢的按钮可点击的元素或 ImageButtons present在的ListView 元素,他们采取的单击事件的控制。所以,你的的ListView 不会得到接受的单击事件的机会。

The first thing what you have to note here is, whenever there are Clickable elements like Buttons or ImageButtons present in your ListView element, they take the control of click events. And so your ListView won't get the chance to accept the click event.

您只需做的是,将可聚焦属性设置为false的按钮的ImageButton 你有你的ListView。但他们仍然将工作没有任何问题,还可以将ListView的 onListItemClick 也将正常工作。

What you simply have to do is, set the focusable attribute to false for the Button or ImageButton you have in your ListView. But still they will work without any problem and also your ListView's onListItemClick will also work.

试试这个,

        <Button  android:id="@+id/textsize_increaser"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/back_button"
        android:focusable="false"
        android:text=" A + "/>

在这里,我加入了这个机器人:可调焦=假并能正常工作。试试吧。

Here I have added this android:focusable="false" and it works fine. try it.

这篇关于点击不工作的列表项列表视图的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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