ListView中的行仍然带有下划线 [英] row of listView remains underLined

查看:351
本文介绍了ListView中的行仍然带有下划线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ListView,我不是如何强调只为一次我点击它选择的行搞清楚。有了这个code行选定的遗体点击它消失时,我选择一个新的一行之后下划线。

i have a listView , and i'm not figuring out on how to underLine the row selected only for the time i click on it. With this code the row selected remains underlined after clicking on it and disappear when i select a new row.

<ListView
        android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@color/list_background"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="1dp"
        android:listSelector="@drawable/list_selector" />

列表选择:

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

    <item android:drawable="@drawable/list_item_bg_normal" android:state_activated="false"/>
    <item android:drawable="@drawable/list_item_bg_pressed" android:state_pressed="true"/>
    <item android:drawable="@drawable/list_item_bg_pressed" android:state_activated="true"/>

</selector>

是有可能实现这个功能?

is it possible to achieve this feature?

更新

我想要实现这个功能。

和后

本code选定行好好尝试一下做什么描述成截图,这一次仍然突出。

with this code the selected row doens't do what is described into screenshots,this one remains underlined.

先谢谢了。

推荐答案

我认为这将是对你有帮助。
在list_selector xml文件,请添加此code

I think it would be helpful for you . in your list_selector xml file please add this code

  <selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:state_enabled="false" android:state_focused="true"
        android:drawable="@android:color/black" />
    <item android:state_pressed="true"
        android:drawable="@android:color/holo_red_dark" />
    <item android:state_focused="true"
        android:drawable="@android:color/holo_red_dark" />

 </selector>

这code是做工精细,我..如果面对任何问题,然后发表评论。谢谢

this code is work fine for me .. if face any problem then comment .. Thank you

这篇关于ListView中的行仍然带有下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆