本文整理汇总了Java中android.widget.SearchView.setQueryHint方法的典型用法代码示例。如果您正苦于以下问题:Java SearchView.setQueryHint方法的具体用法?Java SearchView.setQueryHint怎么用?Java SearchView.setQueryHint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.SearchView
的用法示例。
在下文中一共展示了SearchView.setQueryHint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureFolderSearchView
import android.widget.SearchView; //导入方法依赖的package包/类
private void configureFolderSearchView(Menu menu) {
final MenuItem folderMenuItem = menu.findItem(R.id.filter_folders);
final SearchView folderSearchView = (SearchView) folderMenuItem.getActionView();
folderSearchView.setQueryHint(getString(R.string.folder_list_filter_hint));
folderSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
folderMenuItem.collapseActionView();
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
mAdapter.getFilter().filter(newText);
return true;
}
});
}
示例2: 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;
}
示例3: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.share_menu, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
SearchManager searchManager = (SearchManager) this.getSystemService(Context.SEARCH_SERVICE);
if (searchItem != null) {
mSearchView = (SearchView) searchItem.getActionView();
}
if (mSearchView != null) {
mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
mSearchView.setIconified(false);
mSearchView.setQueryHint(getString(R.string.search_view_hint));
mSearchView.setMaxWidth(getResources().getDimensionPixelOffset(R.dimen.BU_22));
}
setListenerForSearchView();
return super.onCreateOptionsMenu(menu);
}
示例4: 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.
getMenuInflater().inflate(R.menu.lookup, menu);
searchItem = menu.findItem(R.id.action_search);
searchView = (SearchView) searchItem.getActionView();
if (searchView != null)
{
searchView.setQueryHint(getText(R.string.hint));
searchView.setOnQueryTextListener(this);
}
return true;
}
示例5: configureFolderSearchView
import android.widget.SearchView; //导入方法依赖的package包/类
private void configureFolderSearchView(Menu menu) {
final MenuItem folderMenuItem = menu.findItem(R.id.filter_folders);
final SearchView folderSearchView = (SearchView) folderMenuItem.getActionView();
folderSearchView.setQueryHint(getString(R.string.folder_list_filter_hint));
folderSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
folderMenuItem.collapseActionView();
mActionBarTitle.setText(getString(R.string.filter_folders_action));
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
mAdapter.getFilter().filter(newText);
return true;
}
});
folderSearchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
mActionBarTitle.setText(getString(R.string.folders_title));
return false;
}
});
}
示例6: 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.");
}
}
示例7: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
MenuItem searchMenuItem = menu.findItem(R.id.action_search);
MenuItem importItem = menu.findItem(R.id.action_import);
importItem.setVisible(true);
SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setQueryHint(getString(R.string.search));
searchView.onActionViewExpanded();
searchView.clearFocus();
searchView.setSubmitButtonEnabled(false);
searchView.setQueryRefinementEnabled(false);
searchView.setOnQueryTextListener(this);
}
示例8: 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;
}
示例9: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.main_menu, menu);
this.menu = menu;
SearchView addTag = (SearchView) menu.findItem(R.id.addTag).getActionView();
addTag.setQueryHint("myjson id ( ex: 26dyf )");
addTag.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
getTags(query);
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
// Clean magnifier
int searchCloseButtonId = addTag.getContext().getResources().getIdentifier("android:id/search_mag_icon", null, null);
ImageView magIcon = (ImageView) addTag.findViewById(searchCloseButtonId);
magIcon.setLayoutParams(new LinearLayout.LayoutParams(0, 0));
magIcon.setVisibility(View.INVISIBLE);
return true;
}
示例10: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.add_item_shopping_list_menu, menu);
MenuItem searchItem = menu.findItem(R.id.search);
mSearchView = (SearchView) searchItem.getActionView();
mSearchView.setOnQueryTextListener(this);
mSearchView.setQueryHint("Pesquisar");
return true;
}
示例11: 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();
}
示例12: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
/**
* Adds thumb grid fragment specific options to the options menu and stores
* the menu. In this case, the search action is added and enabled.
*
* @param menu
* The menu that will be created
* @param inflater
* The inflater belonging to the menu
*/
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_thumbgrid_fragment, menu);
MenuItem searchMenuItem = menu.findItem(R.id.action_search_thumbgrid);
SearchView searchView = (SearchView) MenuItemCompat
.getActionView(searchMenuItem);
searchView.setOnQueryTextListener(this);
searchView.setQueryHint(getString(R.string.thumb_grid_searchview));
}
示例13: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.latest_activities_menu, menu);
MenuItem searchItem = menu.findItem(R.id.latest_activities_search);
searchView = (SearchView) searchItem.getActionView();
searchView.setQueryHint("Search");
//callback when the query text changes.
searchView.setOnQueryTextListener(this);
//callback to listen for expanding and collapsing events.
MenuItemCompat.setOnActionExpandListener(searchItem, this);
}
示例14: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.projects_menu, menu);
MenuItem menuItem = menu.findItem(R.id.menuProjectSearch);
searchView = (SearchView) menuItem.getActionView();
searchView.setQueryHint("Search");
searchView.setOnQueryTextListener(this);
MenuItemCompat.setOnActionExpandListener(menuItem, this);
}
示例15: 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);
}