使用ContentProvider预填充用户界面

时间:2013-02-25 22:11:06

标签: android android-contentprovider

我玩过Google样本的数据库字典样本。

它的确是这样的:

private void handleIntent(Intent intent) {
    if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        // handles a click on a search suggestion; launches activity to show word
        Intent wordIntent = new Intent(this, WordActivity.class);
        wordIntent.setData(intent.getData());
        startActivity(wordIntent);
    } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        // handles a search query
        String query = intent.getStringExtra(SearchManager.QUERY);
        showResults(query);
    }

我想用数据预填充UI(Google示例有一个空列表)。查询应为“*”。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

好吧我发现它我必须添加这行代码

int count = cursor.getCount();             String countString = getResources()。getQuantityString(                     R.plurals.search_results,伯爵,                     new Object [] {count,query});