我的listview出现了一个诡异的问题。listview是继承listactivity的。
开始我把图片组员放在drawable-hdpi里面,界面没有默认的item背景图片,滚动时出现默认的背景图片。
把图片放在drawable里面时,界面没有出现默认的item背景图片,滚动时出现选中时的背景图片。
我要的效果是界面每个item是默认的图片,滚动时出现选中的背景图片。listview xml<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" ><ListView
android:id="@id/android:list"
android:layout_weight="1"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:listSelector="@drawable/list_picture"
android:drawSelectorOnTop="true"
android:focusable="true"
/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="false"
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/itemi" />
<item android:state_focused="false"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/itemchange" /> <item android:state_focused="true"
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/itemchange" />
<item android:state_focused="true"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/itemchange" />
<item android:state_pressed="true"
android:drawable="@drawable/itemchange" /> </selector> Adapter的配置xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#545454"
android:textSize="25px"
android:textStyle="bold"
android:id="@+id/first"
android:layout_marginLeft="20px"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#545454"
android:id="@+id/second"
android:layout_marginLeft="20px"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FF0000"
android:id="@+id/third"
android:layout_marginLeft="20px"/>
</LinearLayout>请问那位大侠可以解决啊········
开始我把图片组员放在drawable-hdpi里面,界面没有默认的item背景图片,滚动时出现默认的背景图片。
把图片放在drawable里面时,界面没有出现默认的item背景图片,滚动时出现选中时的背景图片。
我要的效果是界面每个item是默认的图片,滚动时出现选中的背景图片。listview xml<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" ><ListView
android:id="@id/android:list"
android:layout_weight="1"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:listSelector="@drawable/list_picture"
android:drawSelectorOnTop="true"
android:focusable="true"
/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="false"
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/itemi" />
<item android:state_focused="false"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/itemchange" /> <item android:state_focused="true"
android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/itemchange" />
<item android:state_focused="true"
android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/itemchange" />
<item android:state_pressed="true"
android:drawable="@drawable/itemchange" /> </selector> Adapter的配置xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#545454"
android:textSize="25px"
android:textStyle="bold"
android:id="@+id/first"
android:layout_marginLeft="20px"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#545454"
android:id="@+id/second"
android:layout_marginLeft="20px"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FF0000"
android:id="@+id/third"
android:layout_marginLeft="20px"/>
</LinearLayout>请问那位大侠可以解决啊········
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货