本文整理匯總了Java中android.widget.SearchView.requestFocus方法的典型用法代碼示例。如果您正苦於以下問題:Java SearchView.requestFocus方法的具體用法?Java SearchView.requestFocus怎麽用?Java SearchView.requestFocus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.SearchView
的用法示例。
在下文中一共展示了SearchView.requestFocus方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onPrepareOptionsMenu
import android.widget.SearchView; //導入方法依賴的package包/類
@Override
public void onPrepareOptionsMenu(Menu menu) {
final MenuItem searchItem = menu.findItem(R.id.action_lookup);
searchView = (SearchView)searchItem.getActionView();
searchView.setOnQueryTextListener(this);
if(openSearch){
searchView.setIconified(false);
searchView.setQuery(textQuery,false);
searchView.requestFocus();
}
}
示例2: onCreateOptionsMenu
import android.widget.SearchView; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.actionbar_menu_atuserfragment, menu);
SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
searchView.setIconifiedByDefault(false);
searchView.setQueryHint(getString(R.string.at_other));
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
if (!TextUtils.isEmpty(newText)) {
if (task != null) {
task.cancel(true);
}
task = new AtUserTask(newText);
task.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
} else {
if (task != null) {
task.cancel(true);
}
atList.clear();
result.clear();
atList = AtUsersDBTask.get(GlobalContext.getInstance().getCurrentAccountId());
for (AtUserBean b : atList) {
result.add(b.getNickname());
}
adapter.notifyDataSetChanged();
}
return false;
}
});
searchView.requestFocus();
}
示例3: onCreateOptionsMenu
import android.widget.SearchView; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.actionbar_menu_searchmainactivity, menu);
final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
final SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
searchView.setIconifiedByDefault(false);
searchView.setSubmitButtonEnabled(false);
searchView.requestFocus();
return super.onCreateOptionsMenu(menu);
}
示例4: onCreate
import android.widget.SearchView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.searchfriends);
mSearchView = (SearchView) findViewById(R.id.searchView1);
mSearchView.setIconifiedByDefault(true);
mSearchView.setQueryHint("按姓名或電子郵件搜索");
mSearchView.setIconified(false);
mSearchView.setFocusable(false);
mSearchView.clearFocus();
mSearchView.requestFocus();
mSearchView.setOnQueryTextListener(this);
mSearchView.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
// TODO Auto-generated method stub
Log.i(MainActivity.TAG, "onfocus2---");
if(hasFocus){
Log.i(MainActivity.TAG, "onfocus---");
}else{
Log.i(MainActivity.TAG, "lost focus---");
}
}
});
mlv = (ListView) findViewById(R.id.search_list);
mSearchText = (TextView) findViewById(R.id.searchText);
mSearchText.setOnClickListener(this);
myRunner = BmobUser.getCurrentUser(RunUser.class);
}