Cly*_*nux 8 android android-layout android-activity
我是Android开发的新手.我正在尝试开发适用于Android的短信应用.我成功阅读了收件箱和联系人并将其显示在一个ListView项目中.现在,我想要实现的是ListView每次点击或触摸或选择这些项目时都会产生连锁反应.我使用listSelector但似乎它不起作用.如果有人可以帮助我,下面是我的代码:
activity_main.xml中
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<ListView
android:id="@+id/msglist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawSelectorOnTop="true"
android:listSelector="#777777" />
Run Code Online (Sandbox Code Playgroud)
小智 17
你打算在你的Adapterfor中夸大一个布局ListView吧?然后,您可以转到layout.xml并设置android:background="?android:selectableItemBackground"为根元素.
注意:这样做只能在API 21(Lollipop)之上发生连锁反应.在Lollipop下,当您触摸该项目时,将出现一个透明的蓝色图层并覆盖您的源内容,这将显示为选择状态.
| 归档时间: |
|
| 查看次数: |
7981 次 |
| 最近记录: |