getStringArray

将String集放在String的resource里面:(QuickSearchBox:config.xml)
<resources>

<!-- Names of corpora that are enabled by default in QSB.
For external single-source corpora, the corpus name is the component name of the
searchable activity. -->
<string-array name="default_corpora" translatable="false">
<item>web</item>
<item>apps</item>
<item>com.android.contacts/.SearchResultsActivity</item>
<item>com.android.providers.applications/.ApplicationLauncher</item>
</string-array>

<!-- Names of corpora that are not shown in the corpus selector, even if they are
enabled in Searchable Items. -->
<string-array name="hidden_corpora" translatable="false">
</string-array>

<!-- The component name of the installed apps source used in QSB -->
<string name="installed_apps_component" translatable="false">com.android.providers.applications/.ApplicationLauncher</string>

<!-- The component name of the browser bookmarks and history source used in QSB -->
<string name="browser_search_component" translatable="false">com.android.browser/.BookmarkSearch</string>

<!-- The component name of the activity that search intents in the Apps corpus are sent to.
If not set, Apps search intents are sent to the Apps suggestion source. -->
<string name="apps_search_activity" translatable="false"></string>

<!-- Number of suggestions slots that are visible above
the onscreen keyboard. These slots will be shared among
the default sources. -->
<integer name="num_suggestions_above_keyboard">4</integer>

</resources>


loading default_corpora这个string集:

private HashSet<String> mDefaultCorpora;
public synchronized boolean isCorpusEnabledByDefault(String corpusName) {
if (mDefaultCorpora == null) {
mDefaultCorpora = loadResourceStringSet(R.array.default_corpora);
}
return mDefaultCorpora.contains(corpusName);
}

 private HashSet<String> loadResourceStringSet(int res) {
HashSet<String> defaultCorpora = new HashSet<String>();
try {
String[] corpora = mContext.getResources().getStringArray(res);
for (String corpus : corpora) {
defaultCorpora.add(corpus);
}
return defaultCorpora;
} catch (Resources.NotFoundException ex) {
Log.e(TAG, "Could not load resource string set", ex);
return defaultCorpora;
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值