Ali*_*Ali 8 android listview xml-layout
我面临一个奇怪的问题,我在我的ListView中添加了一个自定义行,当我删除Button行是可选择的,但是当我添加Button我无法点击该行时,请参阅下面的xml.
<?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" />
Run Code Online (Sandbox Code Playgroud)
请帮助解释为什么会这样.
Pra*_*ani 26
在使用自定义行时.
设置完成后onclickListener为button你getView设置了focusability false.
即 button.setFocusable(false);
并android:descendantFocusability="blocksDescendants"为您的行的布局容器设置.您可以直接设置,android:focusable="false"但这会使您的按钮无法点击.
Car*_*nal 20
尝试设置
android:focusable="false"
android:focusableInTouchMode="false"
Run Code Online (Sandbox Code Playgroud)
你Button的xml.将Button在该行获取焦点,这就是为什么你不能选择你行.
| 归档时间: |
|
| 查看次数: |
8357 次 |
| 最近记录: |