选择自定义列表视图"改变ListView的背景 - 奇怪的现象 - QUOT; [英] Selector for custom list view "Change ListView background - strange behaviour"
问题描述
我用这教程和我要添加选择此列表视图。我想C $ CS一些$,但所行的工作。我怎样才能做到这一点。
我用code为list_selector.xml
< XML版本=1.0编码=UTF-8&GT?;
<选择的xmlns:机器人=http://schemas.android.com/apk/res/android>
<项目安卓state_focused =真
机器人:可绘制=@可绘制/ list_selector_background_focus/>
<项目的android:STATE_ pressed =真
机器人:可绘制=@可绘制/ list_selector_background_ pressed/>
< /选择器>
和我的列表视图
<的ListView
机器人:ID =@ + ID / select_names_tags_lv
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:listSelector =@可绘制/ list_selector
机器人:layout_alignParentTop =假
机器人:layout_gravity =center_vertical>
< / ListView控件>
请检查下面的链接。在这里,我提一个完整的code正确使用列表视图。使用这个我们可以实现任何ListView控件的行为。我们可以嵌入动画也。
<一个href="http://stackoverflow.com/questions/4583349/change-listview-background-strage-behaviour/4583479">Change ListView的背景 - 奇怪的行为
希望这有助于:)
I am using this tutorials and I want to add selectors for this list view. I tried some codes but it doest work. How can I do it.
I used code as list_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true"
android:drawable="@drawable/list_selector_background_focus" />
<item android:state_pressed="true"
android:drawable="@drawable/list_selector_background_pressed" />
</selector>
and my List view
<ListView
android:id="@+id/select_names_tags_lv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:listSelector="@drawable/list_selector"
android:layout_alignParentTop="false"
android:layout_gravity="center_vertical">
</ListView>
Check the following link. here i mentioned a complete code to use listview properly. Using this we can achieve any listview behavior. We can embed animation also.
Change ListView background - strange behaviour
Hope this help :)
这篇关于选择自定义列表视图&QUOT;改变ListView的背景 - 奇怪的现象 - QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!