Android的ListView项突出编程 [英] Android ListView item highlight programmatically

查看:111
本文介绍了Android的ListView项突出编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道它已经被问了一圈,但我还没有找到相当的答案了(新到Android所以抱歉的无知)

I know it's been asked around but I haven't found quite the answer yet (new to Android so sorry about the ignorance)

我的应用程序的启动活动有一个EditText(称为搜索框),一个ListView(名称)和微调(类型)

my app's launch Activity has an EditText (called searchbox) , a ListView (designations) and a Spinner (types)

我用EditText上作为一个搜索框,我要传递字符串通过自定义编辑,以使搜索更为灵活。从那以后,我匹配对最接近我发现在'指定',做

I use the EditText as a searchbox, I have to pass the string through a custom editing to make searching more flexible. After that I match that against the closest approximation I find in 'designations' and do

designations.setSelection(j);

如所预期的,这台所需项目的指定的顶部。但我不能找到一种方法,通过code以突出显示它。

As expected, this sets the desired item to the top of designations. But I can't find a way to highlight it via code.

现在,我只知道,如果设备在触摸模式将不会出现所选项目的高亮显示。因此,在过去的4线我的搜索框的onTextChanged事件是:

NOW, i do know that if the device is in touch mode the highlighting of a selected item won't occur. So the last 4 lines of my searchbox's onTextChanged event are:

        designations.setFocusable(true);            
        designations.setFocusableInTouchMode(true);
        if (match==true)      designations.setSelection(j);
        if (st.length()==0)   designations.setSelection(0);

无济于事。

现在,我没有在搜索框的afterTextChanged(编辑S)的任何code;

now, i don't have any code on searchbox's afterTextChanged(Editable s);

让任何人都可以给我一个线索对此怎么看?

so could anyone give me a clue on this?

问候 〜DH

推荐答案

检查出不是requestFocus(),也许requestChildFocus()

check out requestFocus() and maybe requestChildFocus()

这篇关于Android的ListView项突出编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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