我目前正在研究具有两个片段,一个列表片段和一个详细片段的Android平板电脑应用程序。Android列表查看所选项目样式直到用户滚动才显示
我想让我的列表与人物和电子邮件类似,当选择的项目背景变化,三角形位于列表的右侧。
我目前在设置列表中所选项目的背景时遇到困难。 正如我在列表视图中所理解的,我应该将android:listSelector设置为drawable,并且都应该可以工作。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="8dp"
>
<ListView android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:listSelector="@drawable/selected_background"
/>
<TextView android:id="@id/android:empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="No data. Please check your internet connection." android:gravity="center"/>
</LinearLayout>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="@color/hukd_orange_faded" />
</shape>
当我这样做时,彩色项目的背景不会改变,直到我开始滚动列表。不仅如此,背景闪烁并且经常回到标准背景颜色。
我看了网上,看起来有一个Holo.light的问题,如下所示Android list selector gets stuck when using Theme.Light 我已经尝试了两种状态,但问题仍然存在。
selected_background drawable引用底部的形状。 – bencallis 2012-02-01 00:50:55