点击不工作的列表项列表视图的android列表、视图、工作、android

2023-09-12 07:34:44 作者:把回忆杀死了

我实现了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.