本文整理汇总了Java中android.support.v7.widget.SearchView.setQueryHint方法的典型用法代码示例。如果您正苦于以下问题:Java SearchView.setQueryHint方法的具体用法?Java SearchView.setQueryHint怎么用?Java SearchView.setQueryHint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.SearchView
的用法示例。
在下文中一共展示了SearchView.setQueryHint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.project_menu, menu);
sortByName = menu.findItem(R.id.menu_sort_by_name);
sortByTimeSpent = menu.findItem(R.id.menu_sort_by_time);
sortByName.setChecked(isSortedByName);
sortByTimeSpent.setChecked(isSortedByName);
sortData();
final MenuItem searchItem = menu.findItem(R.id.action_search);
final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setQueryHint(context.getString(R.string.search_hint));
searchView.setOnQueryTextListener(this);
}
示例2: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.questions, menu);
// Setup search widget in action bar
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setQueryHint(getString(R.string.search_hint));
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override public boolean onQueryTextSubmit(String query) {
return false;
}
@Override public boolean onQueryTextChange(String newText) {
presenter.search(newText);
return true;
}
});
return true;
}
示例3: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_search_view, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
mSearchView.setQueryHint("输入歌曲名查找");
mSearchView.onActionViewExpanded();// 当展开无输入内容的时候,没有关闭的图标
mSearchView.setIconified(true);//设置searchView处于展开状态
// searchView.setSubmitButtonEnabled(true);
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
//提交按钮的点击事件
Toast.makeText(SearchViewActivity.this, query, Toast.LENGTH_SHORT).show();
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
//当输入框内容改变的时候回调
// Log.i(TAG,"内容: " + newText);
quertMusic(newText);
return true;
}
});
mSearchAutoComplete = (SearchView.SearchAutoComplete) mSearchView.findViewById(R.id.search_src_text);
//设置输入框内容文字和提示文字的颜色
mSearchAutoComplete.setHintTextColor(getResources().getColor(android.R.color.white));
mSearchAutoComplete.setTextColor(getResources().getColor(android.R.color.white));
return super.onCreateOptionsMenu(menu);
}
示例4: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.song_sort_by, menu);
searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.song_search));
searchView.setOnQueryTextListener(this);
searchView.setQueryHint("Search song");
menu.findItem(R.id.grid_view).setVisible(false);
menu.findItem(R.id.menu_sort_by).setVisible(false);
menu.findItem(R.id.default_folder).setVisible(false);
menu.findItem(R.id.menu_refresh).setVisible(false);
}
示例5: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.home_menu, menu);
searchItem = menu.findItem(R.id.search);
final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchView.setQueryHint(getString(R.string.search_hint));
searchView.setSearchableInfo(searchManager.getSearchableInfo(
new ComponentName(this, SearchActivity.class)));
return true;
}
示例6: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.quran_menu, menu);
final MenuItem item = menu.findItem(R.id.search);
final SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);
final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchView.setQueryHint(getString(R.string.search_hint));
searchView.setSearchableInfo(searchManager.getSearchableInfo(
new ComponentName(this, SearchActivity.class)));
return true;
}
示例7: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.song_sort_by, menu);
searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.song_search));
searchView.setOnQueryTextListener(this);
searchView.setQueryHint("Search song");
menu.findItem(R.id.grid_view).setVisible(false);
menu.findItem(R.id.default_folder).setVisible(false);
}
示例8: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.app_search, menu);
MenuItem searchItem = menu.findItem(R.id.menu_app_search);
MenuItem filterEnabledAppsItem = menu.findItem(R.id.menu_filter_enabled);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setQueryHint(getString(R.string.search_query_hint));
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return recyclerViewShowSearchResult(query);
}
@Override
public boolean onQueryTextChange(String newText) {
return recyclerViewShowSearchResult(newText);
}
});
searchItem.setEnabled(false);
filterEnabledAppsItem.setEnabled(false);
filterEnabledAppsItem.setChecked(mShowOnlyEnabledApps);
return true;
}
示例9: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_search, menu);
MenuItem item = menu.findItem(R.id.action_search);
try {
SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(item);
mSearchView.setQueryHint(getString(R.string.search_by_title));
mSearchView.setInputType(InputType.TYPE_CLASS_TEXT);
mSearchView.setOnQueryTextListener(this);
} catch (Exception e) {
e.printStackTrace();
}
}
示例10: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
final MenuItem searchMenuItem = menu.findItem(R.id.action_search);
final SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setQueryHint(getResources().getString(R.string.search_movies_tv_shows_people));
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
if (!NetworkConnection.isConnected(MainActivity.this)) {
Toast.makeText(MainActivity.this, R.string.no_network, Toast.LENGTH_SHORT).show();
return true;
}
Intent intent = new Intent(MainActivity.this, SearchActivity.class);
intent.putExtra(Constant.QUERY, query);
startActivity(intent);
searchMenuItem.collapseActionView();
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
return true;
}
示例11: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.search_navigation, menu);
MenuItem searchViewItem = menu.findItem(R.id.action_search);
SearchManager searchManager =
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) searchViewItem.getActionView();
searchView.setQueryHint("Search");
searchView.setSearchableInfo(searchManager
.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false);// Do not iconify the widget; expand it by defaul
SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
public boolean onQueryTextChange(String newText) {
// Adapter that will be filtered
classAdapter.getFilter().filter(newText);
return true;
}
public boolean onQueryTextSubmit(String query) {
return true;
}
};
searchView.setOnQueryTextListener(queryTextListener);
return true;
}
示例12: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// Inflate the menu; this adds items to the action bar if it is present.
inflater.inflate(R.menu.menu_search, menu);
MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setQueryHint(getString(R.string.search_hint));
searchView.setIconifiedByDefault(false);
ImageView search_mag_icon = (ImageView) searchView.findViewById(R.id.search_mag_icon);
search_mag_icon.setImageResource(0);
LinearLayout search_plate = (LinearLayout) searchView.findViewById(R.id.search_plate);
search_plate.setBackgroundColor(Color.TRANSPARENT);
searchView.setOnQueryTextListener(mQueryListener);
}
示例13: onCreateOptionsMenu
import android.support.v7.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.menu_main, menu);
MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setQueryHint(getString(R.string.search_hint));
searchView.setIconifiedByDefault(false);
ImageView search_mag_icon = (ImageView) searchView.findViewById(R.id.search_mag_icon);
search_mag_icon.setImageResource(0);
LinearLayout search_plate = (LinearLayout) searchView.findViewById(R.id.search_plate);
search_plate.setBackgroundColor(Color.TRANSPARENT);
searchView.setOnQueryTextListener(mQueryListener);
return true;
}
示例14: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.song_sort_by, menu);
searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.song_search));
searchView.setOnQueryTextListener(this);
searchView.setQueryHint("Search song");
if (Extras.getInstance().songView()) {
menu.findItem(R.id.grid_view).setVisible(true);
} else {
menu.findItem(R.id.grid_view).setVisible(false);
}
menu.findItem(R.id.default_folder).setVisible(false);
}
示例15: onCreateOptionsMenu
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.filesystem__menu, menu);
_searchItem = menu.findItem(R.id.action_search);
_searchView = (SearchView) _searchItem.getActionView();
SearchManager searchManager = (SearchManager) _context.getSystemService(SEARCH_SERVICE);
_searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
_searchView.setQueryHint(getString(R.string.search_documents));
if (_searchView != null) {
_searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
if (query != null) {
if (isVisible())
search(query);
}
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
if (newText != null) {
if (isVisible()) {
if (newText.equalsIgnoreCase("")) {
clearSearchFilter();
} else {
search(newText);
}
}
}
return false;
}
});
_searchView.setOnQueryTextFocusChangeListener((v, hasFocus) -> {
MenuItem item = menu.findItem(R.id.action_import);
if (item != null) {
item.setVisible(hasFocus);
}
if (!hasFocus) {
_searchItem.collapseActionView();
}
});
}
ContextUtils cu = ContextUtils.get();
cu.tintMenuItems(menu, true, Color.WHITE);
cu.setSubMenuIconsVisiblity(menu, true);
}