在ListView控件时,列表项按钮onListItemClick不起作用 [英] In ListView when list item has button onListItemClick doesn't work

查看:116
本文介绍了在ListView控件时,列表项按钮onListItemClick不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的ListView我的列表项视图如下

In my ListView my list item has view as below

这是我的row.xml布局

this is my row.xml layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/Peru"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:background="@drawable/et_back_yellow"
        android:orientation="horizontal" >

        <ImageButton
            android:id="@+id/ib_edit"
            android:layout_width="35dp"
            android:layout_height="30dp"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="5dp"
            android:layout_weight="1"
            android:background="@drawable/ib_selector"
            android:contentDescription="@string/edit"
            android:src="@drawable/edit" />

        <TextView
            android:id="@+id/tv_date"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="100"
            android:gravity="center_vertical|center_horizontal" />

        <TextView
            android:id="@+id/tv_time"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="100"
            android:gravity="center_vertical|center_horizontal" />

        <ImageButton
            android:id="@+id/ib_delete"
            android:layout_width="35dp"
            android:layout_height="30dp"
            android:layout_marginBottom="5dp"
            android:layout_marginRight="5dp"
            android:layout_marginTop="5dp"
            android:layout_weight="1"
            android:background="@drawable/ib_selector"
            android:contentDescription="@string/edit"
            android:src="@drawable/delete" />
    </LinearLayout>

    <EditText
        android:id="@+id/et_note"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/title"
        android:layout_alignRight="@+id/title"
        android:layout_below="@+id/title"
        android:layout_marginTop="5dp"
        android:ems="10"
        android:inputType="textMultiLine" 
        android:background="@color/yellow">

        <requestFocus />
    </EditText>

</RelativeLayout>

当我在列表项点击onListItemClick方法不会当我删除按钮形成row.xml它提前works.Can任何人的帮助me.Thanks work.But。

When i click on list item the onListItemClick method doesn't work.But when i delete the buttons form row.xml it works.Can anyone help me.Thanks in advance.

推荐答案

的LinearLayout RelativeLayout的:

android:descendantFocusability="blocksDescendants"

这篇关于在ListView控件时,列表项按钮onListItemClick不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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