0

I am using a sliding menu in my app.In this menu there is a listview.I am using a row layout for the row items in my listview.

My row layout is like:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/color_back_frag"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/list_item_selector"
android:orientation="horizontal" >

<ImageView
    android:id="@+id/row_icon"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:padding="10dp"
    android:src="@drawable/ic_launcher" />

<TextView
    android:id="@+id/row_title"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:gravity="center_vertical"
    android:padding="10dp"
    android:text="Medium Text"
    android:textAppearance="@android:style/TextAppearance.Medium"
    android:textColor="@color/white" />

</LinearLayout>

and my list_item_selector is like:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@drawable/and_satir_01" android:state_pressed="true"/>
<item android:drawable="@drawable/and_satir_01" android:state_selected="true"/>
<item android:drawable="@drawable/and_satir_02"/>

</selector>

When I click on a list item the background changes for a moment like a flash.But I want it to be like in facebook app.In facebook app when you click on a sliding menu list item the background stays with the changed bacground image during the "slide-in" process. I am not sure if I had told this clearly.

What I want is, after the list item click, the list item background should stay with the "state_pressed" background until the slide-in process finished. Is there any way to do it?

4

1 回答 1

1

From ListView docs:

By default, lists do not have any choice behavior. By setting the choiceMode to singleChoice, the list allows up to one item to be in a chosen state.

So you could try to set android:choiceMode="singleChoice" param for your ListView first of all.

Hope it help you!

于 2013-01-07T10:34:46.983 回答