[英]Selecting Rows in Listview and Setting up OnClickListener - Android
我有一个使用Adapter
从SQLite
数据库中读取的应用程序,以在RelativeLayout
显示结果(如下所示的代码)。
我有两个问题:
1)列表中的行不再可选。 在添加图像之前(我认为),可以将它们突出显示/选定 。
编辑 -这似乎是由我添加到行中的白色背景引起的? 有谁知道我该如何纠正?
2)解决以上问题后,如何设置OnClickListener
来检测何时有人选择了列表中的项目?
这是布局的代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="70dip"
android:background="@drawable/white"
android:orientation="horizontal"
android:padding="10sp">
<ImageView
android:id="@+id/Logo"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="6dip" />
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF000000"
android:textStyle="bold"
android:textSize="12sp"
android:typeface="sans"
android:layout_toRightOf="@id/Logo" />
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:layout_below="@id/name"
android:textColor="#0000CC"
android:layout_toRightOf="@id/Logo" />
<TextView
android:id="@+id/address"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="12sp"
android:layout_below="@id/description"
android:textColor="#990000"
android:layout_toRightOf="@id/Logo" />
</RelativeLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.