本文整理汇总了Java中com.actionbarsherlock.widget.SearchView.OnQueryTextListener类的典型用法代码示例。如果您正苦于以下问题:Java OnQueryTextListener类的具体用法?Java OnQueryTextListener怎么用?Java OnQueryTextListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OnQueryTextListener类属于com.actionbarsherlock.widget.SearchView包,在下文中一共展示了OnQueryTextListener类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateOptionsMenu
import com.actionbarsherlock.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getSupportMenuInflater().inflate(R.menu.main, menu);
final MenuItem searchMenuItem = menu.findItem(R.id.search);
SearchView searchView = (SearchView) searchMenuItem.getActionView();
searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
searchMenuItem.collapseActionView();
showSearchFragment(query);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
return true;
}
示例2: onPrepareOptionsMenu
import com.actionbarsherlock.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
@Override
public void onPrepareOptionsMenu(Menu menu) {
if(Build.VERSION.SDK_INT >= 8) {
SearchView searchView = new SearchView(getSherlockActivity().getSupportActionBar().getThemedContext());
searchView.setQueryHint("Buscar paradas…");
searchView.setIconified(true);
searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
buscarParadas(query.toString());
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
buscarParadas(newText);
return false;
}
});
MenuItem buscar = menu.findItem(R.id.buscar);
buscar.setVisible(true);
buscar.setActionView(searchView);
}
super.onPrepareOptionsMenu(menu);
}
示例3: onCreateOptionsMenu
import com.actionbarsherlock.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
// Search view
getSupportMenuInflater().inflate(R.menu.search, menu);
// Settings
getSupportMenuInflater().inflate(R.menu.activity_base, menu);
// Theme the search icon
mResources.setSearchIcon(menu);
final SearchView searchView = (SearchView)menu.findItem(R.id.menu_search).getActionView();
// Add voice search
final SearchManager searchManager = (SearchManager)getSystemService(Context.SEARCH_SERVICE);
final SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName());
searchView.setSearchableInfo(searchableInfo);
// Perform the search
searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(final String query) {
// Open the search activity
NavUtils.openSearch(BaseActivity.this, query);
return true;
}
@Override
public boolean onQueryTextChange(final String newText) {
// Nothing to do
return false;
}
});
return super.onCreateOptionsMenu(menu);
}
示例4: onCreateOptionsMenu
import com.actionbarsherlock.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
// Search view
getSupportMenuInflater().inflate(R.menu.search, menu);
// Theme the search icon
mResources.setSearchIcon(menu);
final SearchView searchView = (SearchView)menu.findItem(R.id.menu_search).getActionView();
// Add voice search
final SearchManager searchManager = (SearchManager)getSystemService(Context.SEARCH_SERVICE);
final SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName());
searchView.setSearchableInfo(searchableInfo);
// Perform the search
searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(final String query) {
// Open the search activity
NavUtils.openSearch(AudioPlayerActivity.this, query);
return true;
}
@Override
public boolean onQueryTextChange(final String newText) {
// Nothing to do
return false;
}
});
// Favorite action
getSupportMenuInflater().inflate(R.menu.favorite, menu);
// Shuffle all
getSupportMenuInflater().inflate(R.menu.shuffle, menu);
// Share, ringtone, and equalizer
getSupportMenuInflater().inflate(R.menu.audio_player, menu);
// Settings
getSupportMenuInflater().inflate(R.menu.activity_base, menu);
return true;
}
示例5: onCreateOptionsMenu
import com.actionbarsherlock.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
@Override
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
final SherlockFragmentActivity activity = (SherlockFragmentActivity) getActivity();
final SearchView searchView = new SearchView(activity
.getSupportActionBar().getThemedContext());
searchView.setQueryHint(getString(R.string.search));
final int searchId = 1337;
menu.add(Menu.NONE, searchId, 1, getString(R.string.search))
.setIcon(R.drawable.abs__ic_search)
.setActionView(searchView)
.setShowAsAction(
MenuItem.SHOW_AS_ACTION_ALWAYS
| MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextChange(final String newText) {
return false;
}
@Override
public boolean onQueryTextSubmit(final String query) {
searchTerms = query;
search();
// Hide keyboard
final InputMethodManager imm = (InputMethodManager) activity
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(searchView.getWindowToken(), 0);
// Hide searchView
menu.findItem(searchId).collapseActionView();
return false;
}
});
super.onCreateOptionsMenu(menu, inflater);
}