本文整理汇总了Java中android.support.v7.widget.SearchView.requestFocus方法的典型用法代码示例。如果您正苦于以下问题:Java SearchView.requestFocus方法的具体用法?Java SearchView.requestFocus怎么用?Java SearchView.requestFocus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.SearchView
的用法示例。
在下文中一共展示了SearchView.requestFocus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
// Get the SearchView and set the searchable configuration
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.search_btn).getActionView();
// Assumes current activity is the searchable activity
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
searchView.setMaxWidth(Integer.MAX_VALUE);
searchView.requestFocus(1);
//searchView.setSubmitButtonEnabled(true);
return true;
}
示例2: setupSearchView
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
private void setupSearchView(Menu menu) {
ActionBar actionBar = getSupportActionBar();
Context context = actionBar != null ? actionBar.getThemedContext() : this;
SearchView searchView = new SearchView(context);
searchView.setIconifiedByDefault(false);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String queryText) {
mEasyRecycleAdapter.setItems(new ArrayList<PointOfInterest>());
if (queryText.length() > 0) {
getAutocompleteResults(queryText);
} else {
mSubscriptions.unsubscribe();
mProgressBar.setVisibility(View.GONE);
}
return false;
}
});
searchView.requestFocus();
menu.findItem(R.id.action_search).setActionView(searchView);
}
示例3: setupSearchView
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
private void setupSearchView(SearchView searchView) {
searchView.setIconifiedByDefault(false);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
if (searchManager != null) {
SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName());
searchView.setSearchableInfo(searchableInfo);
}
searchView.setOnQueryTextListener(this);
searchView.requestFocus();
searchView.setMaxWidth(Integer.MAX_VALUE);
}