本文整理汇总了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);
}