本文整理汇总了Java中android.widget.SearchView.setIconifiedByDefault方法的典型用法代码示例。如果您正苦于以下问题:Java SearchView.setIconifiedByDefault方法的具体用法?Java SearchView.setIconifiedByDefault怎么用?Java SearchView.setIconifiedByDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.SearchView
的用法示例。
在下文中一共展示了SearchView.setIconifiedByDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_main, menu);
// Get the SearchView and set the searchable configuration
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
// Assumes current activity is the searchable activity
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(true); // Do not iconify the widget; expand it by default
searchView.setQueryHint(getResources().getString(R.string.search_hint));
return true;
}
示例2: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
// Associate searchable configuration with the SearchView
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.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
model.search(query);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return true;
}
});
}
示例3: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
SearchManager mSearchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView mSearchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
mSearchView.setSearchableInfo(mSearchManager.getSearchableInfo(getComponentName()));
mSearchView.setIconifiedByDefault(true);
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
mAdapter.getFilter().filter(query);
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
mAdapter.getFilter().filter(newText);
return false;
}
});
return true;
}
示例4: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_activity_actions, menu);
// Get the SearchView and set the searchable configuration
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.action_search)
.getActionView();
searchView.setSearchableInfo(searchManager
.getSearchableInfo(new ComponentName(this,
ChannelSearchActivity.class)));
searchView.setIconifiedByDefault(false);
searchView.setSubmitButtonEnabled(true);
return super.onCreateOptionsMenu(menu);
}
示例5: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu){
MenuInflater inflater = getMenuInflater();
inflater.inflate (R.menu.options_menu, menu);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
MenuItem searchItem = menu.findItem(R.id.search_bar);
SearchView searchView = (SearchView) searchItem.getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false);
searchView.setSubmitButtonEnabled(false);
searchView.setOnQueryTextListener(this);
return super.onCreateOptionsMenu(menu);
}
示例6: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_menu, menu);
// Associate searchable configuration with the SearchView
SearchManager searchManager =
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(
searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
searchView.onActionViewExpanded();
return true;
}
示例7: onCreate
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.find_user);
allUsers = new ArrayList<>();
resultsList = new ArrayList<>();
resultCount = (TextView) findViewById(R.id.results_found);
resultsListView = (RecyclerView) findViewById(R.id.search_listview);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
resultsListView.setLayoutManager(layoutManager);
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(this, DividerItemDecoration.VERTICAL);
resultsListView.addItemDecoration(itemDecoration);
// Set up Search View
SearchView searchFriends = (SearchView) findViewById(R.id.user_search);
searchFriends.setQueryHint("Search for a user");
searchFriends.setIconifiedByDefault(false);
searchFriends.setOnQueryTextListener(this);
// Get all users
ElasticSearchController.GetAllUsers getUsersTask = new ElasticSearchController.GetAllUsers();
getUsersTask.execute();
try {
ArrayList<UserAccount> tempUsers = getUsersTask.get();
allUsers.addAll(tempUsers);
} catch (Exception e) {
Log.i("HabitUpDEBUG", "Failed to get all users.");
}
}
示例8: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.database_opened, menu);
getMenuInflater().inflate(R.menu.main, menu);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchMenuItem = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false);
searchView.requestFocusFromTouch();
return true;
}
示例9: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_menu, menu);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false);
}
return true;
}
示例10: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_menu, menu);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false);
}
return true;
}
示例11: onCreateView
import android.widget.SearchView; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.search_users_groups_layout, container, false);
// Get the SearchView and set the searchable configuration
SearchView searchView = (SearchView) view.findViewById(R.id.searchView);
SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
searchView.setSearchableInfo(searchManager.getSearchableInfo(
getActivity().getComponentName()) // assumes parent activity is the searchable activity
);
searchView.setIconifiedByDefault(false); // do not iconify the widget; expand it by default
searchView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); // avoid fullscreen with softkeyboard
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
Log_OC.v(TAG, "onQueryTextSubmit intercepted, query: " + query);
return true; // return true to prevent the query is processed to be queried;
// a user / group will be picked only if selected in the list of suggestions
}
@Override
public boolean onQueryTextChange(String newText) {
return false; // let it for the parent listener in the hierarchy / default behaviour
}
});
return view;
}
示例12: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
SearchView searchEditText = new SearchView(this);
searchEditText.setIconifiedByDefault(true);
searchEditText.setOnQueryTextListener(this);
searchEditText.setQueryHint("Search Here");
menu.add(0, 2, 2, "Search").setActionView(searchEditText).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
menu.add(1, 0, 0, "New word").setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
menu.add(2, 1, 1, "Save").setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
return true;
}
示例13: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_activity_actions, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
mSearchView = (SearchView) searchItem.getActionView();
mSearchView.setIconifiedByDefault(true);
mSearchView.setOnQueryTextListener(this);
return super.onCreateOptionsMenu(menu);
}
示例14: 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();
}
示例15: 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);
}