【问题标题】:How to higlight a search word如何突出显示搜索词
【发布时间】:2012-05-21 04:28:29
【问题描述】:

我正在创建一个搜索引擎,如 android 中的应用程序,我想知道如何在此链接中的列表视图中突出显示搜索的单词。http://androidbible.blogspot.com/2010/12/color-highlight-and-whole-word-search.html 提前感谢那些想要帮助的人...

【问题讨论】:

    标签: android listview search-engine highlight


    【解决方案1】:

    我觉得你可以试试SpannableString

    下面只是一个演示。

        TextView tv = (TextView) findViewById(R.id.textView1);
        SpannableString str = new SpannableString("hello");
        BackgroundColorSpan span = new BackgroundColorSpan(Color.YELLOW);
        str.setSpan(span, 0, 2, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
        tv.setText(str);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-23
      • 2012-08-04
      • 2014-02-13
      • 2015-01-28
      • 1970-01-01
      • 2016-11-25
      相关资源
      最近更新 更多