這不完全是一個答案,但請記住,輸入型過濾器的用處可在您使用的IME隊伍;一些鍵盤不會輕易遵守這些輸入類型...我學會了這種艱難的方式。 :(
考慮到這一點,你是否嘗試過使用其他輸入類型來查看它們是否會粘住?如果它們堅持,它可能是一個IME問題,如果它們不這樣,這可能是一個問題在你試圖強制輸入型
現在,射擊在一個答案:
你可以嘗試,在onCreateOptionsMenu,通過該菜單項的ID做了查詢,鑄造到搜索查看,並在代碼中設置輸入類型:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.default_menu, menu);
if (MyApplication.SUPPORTS_HONEYCOMB) { // quick check for API level
// If we have the honeycomb API, set up the search view
MenuItem searchItem = menu.findItem(R.id.search);
SearchView search = (SearchView) searchItem.getActionView();
// your code here. something like:
search.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_NORMAL);
// you also likely want to set up your search listener here.
}
// I'm using ActionBarCompat, in which case
// calling super after populating the menu is necessary here to ensure that the
// action bar helpers have a chance to handle this event.
return super.onCreateOptionsMenu(menu);
}
看到這個[鏈接](http://developer.android.com/reference/android/widget/SearchView.html) – 2012-03-03 05:10:20
感謝您的意見,但在知道StackOverflow的問題之前,我知道要查閱Android文檔:P – 2012-03-03 05:15:26
此外,文檔似乎表明這種方法應該沒有任何問題。 – 2012-03-03 05:16:28