【发布时间】:2014-01-22 20:49:02
【问题描述】:
我所做的只是改变了背景的颜色,当我单击列表项时,我再也无法获得效果。我需要改变什么? 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"
android:background="#FFFFFF">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:layout_margin="10dp"
android:src="@drawable/file" />
<EditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/image"
android:layout_marginTop="30dp"
android:layout_toRightOf="@+id/image"
android:background="@null"
android:includeFontPadding="true"
android:textColor="#000000" />
</RelativeLayout>
我想要做的只是如下所示,但是当我单击列表项时带有颜色变化:
更新:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ListView android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFAF0"
android:dividerHeight="1dp"
android:layout_margin="0dp"
android:divider="#808080"/>
</RelativeLayout>
【问题讨论】:
-
你试过清理项目吗?
-
请贴出listview的xml代码
-
@VishwasSharma 我有。当我单击时我收到通知,当我这样做时我不再看到突出显示的列表视图
-
@T.V.检查更新。
-
但是您刚刚将背景颜色设置为列表视图。因此,在开始时它以该颜色显示。您必须在 xml 中将背景设置为 listColor,或者您可以在 ListView 的项目单击时动态更改。