【问题标题】:Indexable Listview in AndroidAndroid中的可索引列表视图
【发布时间】:2013-05-30 19:30:15
【问题描述】:

我试图在我的列表视图中获取一个可索引的列表。我推荐了this。但是在使用代码时,我在 StringMatcher 类中使用韩语字符时遇到了错误。谁能解释一下这个类的用法?英文字符也需要这个类吗?

提前致谢。

【问题讨论】:

  • 看看这个,也许这有帮助stackoverflow.com/questions/12560919/…
  • 感谢 V4Vendetta。这对我有点帮助。但是在点击索引中的字母时,只会显示一条 toast 消息,指示已点击的字母。

标签: android android-listview


【解决方案1】:

需要进行一些更改才能使其正常工作。为了编译项目并摆脱韩文文本更新 StringMatcher 类

package com.woozzu.android.util;

public class StringMatcher {
    public static boolean match(String value, String keyword) {
        if (value == null || keyword == null)
            return false;
        if (keyword.length() > value.length())
            return false;

        int i = 0, j = 0;
        do {
            int vi = value.charAt(i);
            int kj = keyword.charAt(j);
            if (isKorean(vi) && isInitialSound(kj)) {
            } else {
                if (vi == kj) {
                    i++;
                    j++;
                } else if (j > 0)
                    break;
                else
                    i++;
            }
        } while (i < value.length() && j < keyword.length());

        return (j == keyword.length())? true : false;
    }

    private static boolean isKorean(int i) {
        return false;
    }

    private static boolean isInitialSound(int i) {
        return false;
    }
}

【讨论】:

  • 谢谢@Akshat Jaiswal
  • @AkshatJaiswal 精湛
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-09
  • 2016-10-07
  • 2011-04-02
  • 2011-07-13
  • 1970-01-01
  • 2015-08-05
相关资源
最近更新 更多