【发布时间】:2013-04-25 15:04:30
【问题描述】:
我有带有自定义 ArrayAdapter 的 ListActivity 和以下列表项布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:paddingTop="5dip"
android:paddingBottom="5dip" >
<ImageView
android:id="@+id/image"
android:layout_width="48dip"
android:layout_height="48dip" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="24.5sp" />
<TextView
android:id="@+id/text2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="12sp"/>
</LinearLayout>
我的问题是,我无法单击任何列表项。到目前为止我尝试过的是
将focusable、clickable 设置为false(我发现这可能有帮助)到我的 ImageView
但不幸的是,问题仍然存在。请帮忙,这一直困扰着我一整天。谢谢。
编辑:好的,所以威廉的回答帮助我解决了这个问题,现在唯一的问题是当我将背景颜色更改为黑色时,单击项目不会突出显示它(通过在清单中为此列表活动设置新主题) .
这是我在 res/values/styles/ 文件夹中的活动主题 <style name="ContentsListTheme">
<item name="android:background">@color/black</item>
</style> 的自定义样式。
再次说明,默认的 ListActivity 背景颜色是白色。我要黑色当我从上面应用样式时,单击时列表活动项突出显示被禁用。如何再次启用它,以默认突出显示颜色?
【问题讨论】:
标签: android imageview listactivity listadapter