开发者

Android: ListView item deselected after tap

开发者 https://www.devze.com 2023-02-12 08:25 出处:网络
I have a ListView with a pretty standard view for each row - an icon with two labels (source below). I can use the keyboard to select items (which stay selected), but if I tap an item it\'s selected t

I have a ListView with a pretty standard view for each row - an icon with two labels (source below). I can use the keyboard to select items (which stay selected), but if I tap an item it's selected then deselected. Should it not stay selected? I've tried overriding the onKeyDown and onListItemClick events and just returning super.onKeyDown, but then the app just hangs.

The source of each row is:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="5dip">
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="fill_parent"
开发者_高级运维            android:layout_height="fill_parent">
            <ImageView android:id="@+id/icon"
                       android:layout_width="wrap_content"
                       android:layout_height="wrap_content"
                       android:minWidth="24px"
                       android:maxWidth="24px"
                       android:layout_marginRight="4dip"
                       android:layout_gravity="center_vertical"/>
            <TextView android:id="@+id/name"
                android:textSize="18dip"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
        </LinearLayout>
        <TextView android:id="@+id/description"
           android:textSize="12dip"
           android:layout_marginTop="2dip"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"/>
</LinearLayout>


A item of a ListView doesn't stay selected when you touch it. The selection is only there for you to see, where your selection is when you use a keyboard/touchball.

Take a look in the ListViews of the settings (telefon info) there you can click on items and they don't stay selected...

0

精彩评论

暂无评论...
验证码 换一张
取 消