0

嗨,我想尝试为需要字典的 android 手机制作一个简单的应用程序。我想用 urbandictionary.com 作为参考网站。有没有什么技术可以提取词库中所有带有定义的词及其各自的词?

4

1 回答 1

1

我正在查看在以下位置找到的 Google 示例

http://developer.android.com/resources/samples/SearchableDictionary/index.html

看来他们只是在这个例子中添加了他们的话

        private void loadWords() throws IOException {
        Log.d(TAG, "Loading words...");
        final Resources resources = mHelperContext.getResources();
        InputStream inputStream = resources.openRawResource(R.raw.definitions);
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));

        try {
            String line;
            while ((line = reader.readLine()) != null) {
                String[] strings = TextUtils.split(line, "-");
                if (strings.length < 2) continue;
                long id = addWord(strings[0].trim(), strings[1].trim());
                if (id < 0) {
                    Log.e(TAG, "unable to add word: " + strings[0].trim());
                }
            }
        } finally {
            reader.close();
        }
        Log.d(TAG, "DONE loading words.");
    }

但是,当我查找 R.raw.definitions 时,该目录为空。

http://developer.android.com/resources/samples/SearchableDictionary/res/raw/index.html

于 2012-06-19T15:45:33.217 回答