Android的ListView的巴顿是不可选(可点击) [英] Android ListView with Button is not selectable(Clickable)

查看:114
本文介绍了Android的ListView的巴顿是不可选(可点击)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临着一个奇怪的问题,我已经在我的ListView添加了自定义行,当我删除按钮行是可选择的,但是我添加按钮,我不能够单击该行,请参阅下面的XML。

I am facing a strange problem, I have added a Custom row in my ListView when I am removing the Button row is selectable, but as I add Button I am not able to click the row, please see the xml below.

<?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" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="77dp"
    android:layout_height="77dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="18dp"
    android:src="@drawable/company_logo" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:text="Idds  sdsad "
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@+id/imageView1"

    android:layout_below="@+id/textView1"
    android:textColor="#8b8989"
    android:layout_marginLeft="5dp"
    android:text="Tap to see detail"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView2"
    android:layout_centerHorizontal="true"
    android:text="Button" />

请帮忙为什么发生这种情况。

Please help why this is happening.

推荐答案

尝试设置

android:focusable="false"
android:focusableInTouchMode="false"

你的在XML按钮。该按钮获取焦点在列,这就是为什么你不能选择你行。

to your Button in the xml. The Button gain focus over the row, that's why you can't select your row.

这篇关于Android的ListView的巴顿是不可选(可点击)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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