发现在Android版的EditText文本 [英] Find text in a EditText Android

查看:116
本文介绍了发现在Android版的EditText文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有这个问题的 如何查找文本在android系统?通过搜索查看或EditText上 ,但它不是正确回答我的问题。我有一个EditText中会有文字。我想找到的所有文字OCCURENCES并突出它像按Ctrl + F 谷歌浏览器(Windows)中。此外,还会有像查找下一个按钮。我有一个形象,告诉我想要什么。

I know there is this question How to find text in android? through an SearchView or EditText but its not answering my question properly. I have an EditText in which there will be text. I want to find all the text occurences and highlight it like the Ctrl + F in Google Chrome (Windows). Also, there will be a button like "Find Next". I got a image to tell what I want.

我想要什么

得到的图像 如何查找文本在android系统?通过搜索查看或EditText上

Got the image from How to find text in android? through an SearchView or EditText

我希望所有的具体文本以黄色突出显示与当前文本在阅读中突出显示。像上面的图片。

I want all the specific text to be highlighted in yellow and the current text to be highlighted in read. Like the image above.

推荐答案

我认为你可以使用<一个href=\"http://stackoverflow.com/questions/10799732/highlight-all-words-that-is-searched-via-edittext\">this code。
它应该很好地工作你的情况下,唯一的区别是,而不是在foreach条款,你将不得不使用int

i think you can use this code. It should work perfectly for your case, the only difference is that instead of the foreach clause, you will have to use an int

int i = *numberOfRecurrences*;
int index = *recurrenceShown*;

不是你可以添加的下次的按钮和foreach点击执行

than you can add the next button and foreach click doing

index++;

和比改变的首页的复发背景和其他复发的颜色设置恢复到默认的。

and than change the background of index recurrences and setting back the color of other recurrences to the default one.

如果您有任何疑问问:)

if you have questions ask :)

这篇关于发现在Android版的EditText文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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