本文整理汇总了Java中android.widget.SearchView.OnQueryTextListener类的典型用法代码示例。如果您正苦于以下问题:Java OnQueryTextListener类的具体用法?Java OnQueryTextListener怎么用?Java OnQueryTextListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OnQueryTextListener类属于android.widget.SearchView包,在下文中一共展示了OnQueryTextListener类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateOptionsMenu
import android.widget.SearchView.OnQueryTextListener; //导入依赖的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.main_menu, 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.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
Bundle bundle = new Bundle();
bundle.putString("query", query);
Fragment fragment = new SearchFragment();
fragment.setArguments(bundle);
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.main_container, fragment).commit();
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return true;
}
});
// Assumes current activity is the searchable activity
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
return true;
}
示例2: onCreateOptionsMenu
import android.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
getMenuInflater().inflate(R.menu.main, menu);
SearchManager searchManager = (SearchManager) this.getSystemService(Context.SEARCH_SERVICE);
SearchView searchView =
(SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setQueryHint(getResources().getText(R.string.search_hint));
searchView.setSearchableInfo(
searchManager.getSearchableInfo(this.getComponentName()));
searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
// TODO Auto-generated method stub
return false;
}
});
return super.onCreateOptionsMenu(menu);
}
示例3: createSearchQueryListener
import android.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
/**
* Creates and returns a listener, which allows to start a search query when the user enters
* text.
*
* @return The listener, which has been created, as an instance of the type {@link
* OnQueryTextListener}
*/
private OnQueryTextListener createSearchQueryListener() {
return new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(final String query) {
return false;
}
@Override
public boolean onQueryTextChange(final String newText) {
search(newText);
return true;
}
};
}
示例4: newOnQueryTextListener
import android.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
public static Object newOnQueryTextListener(final OnQueryTextListenerCompatBridge listener) {
return new OnQueryTextListener() {
public boolean onQueryTextSubmit(String query) {
return listener.onQueryTextSubmit(query);
}
public boolean onQueryTextChange(String newText) {
return listener.onQueryTextChange(newText);
}
};
}
示例5: newOnQueryTextListener
import android.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
public static Object newOnQueryTextListener(final OnQueryTextListenerCompatBridge listener) {
return new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return listener.onQueryTextSubmit(query);
}
@Override
public boolean onQueryTextChange(String newText) {
return listener.onQueryTextChange(newText);
}
};
}
示例6: makeSearchMenuEntry
import android.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
@Override
public MenuItem makeSearchMenuEntry(Menu menu) {
MenuItem item = menu.add("Search");
searchView = new SearchView(diskusage);
origSearchBackground = searchView.getBackground();
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
item.setIcon(android.R.drawable.ic_search_category_default);
item.setActionView(searchView);
if (searchPattern != null) {
searchView.setIconified(false);
searchView.setQuery(searchPattern, false);
}
searchView.setOnCloseListener(new OnCloseListener() {
@Override
public boolean onClose() {
Log.d("diskusage", "search closed");
searchPattern = null;
diskusage.applyPatternNewRoot(masterRoot, null);
return false;
}
});
searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
onQueryTextChange(query);
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
Log.d("diskusage", "search query changed to: " + newText);
searchPattern = newText;
applyPattern(searchPattern);
return true;
}
});
return item;
}
示例7: onCreateOptionsMenu
import android.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.mark, menu);
mBtRetry = menu.findItem(R.id.bt_lost);
mSearchBox = menu.findItem(R.id.search);
mSearchView = (SearchView) mSearchBox.getActionView();
mSearchView.setQueryHint(getString(R.string.mark_editor_hint));
mSearchView.setOnSearchClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setItemsVisibility(menu, mSearchBox, false);
mSearchView.requestFocus();
}
});
mSearchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
setItemsVisibility(menu, mSearchBox, true);
return false; // true = prevent collapse mSearchView
}
});
mSearchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
mMarksAdapter.getFilter().filter(newText);
return true;
}
});
return true;
}
示例8: onCreateOptionsMenu
import android.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// TODO Auto-generated method stub
mActivity.getMenuInflater().inflate(R.menu.main, menu);
SearchManager searchManager = (SearchManager) mActivity.getSystemService(Context.SEARCH_SERVICE);
SearchView searchView =
(SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setQueryHint(getResources().getText(R.string.search_hint));
searchView.setSearchableInfo(
searchManager.getSearchableInfo(mActivity.getComponentName()));
searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
// TODO Auto-generated method stub
Intent i = new Intent(mActivity, SearchMangaActivity.class);
i.putExtra(SearchMangaActivity.ARG_MANGA_KEYWORD, query);
startActivity(i);
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
// TODO Auto-generated method stub
return false;
}
});
super.onCreateOptionsMenu(menu, inflater);
}
示例9: onCreateOptionsMenu
import android.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
mSearchView = (SearchView)
menu.findItem(R.id.search_MenuItem).getActionView();
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
public boolean onQueryTextChange(String newText) {
LOGI("onQueryTextChange newText='" + newText + "'" +
" filter='" + getSearchFilter() + "'");
if (!equalFilters(mLastRequestedFilter, getSearchFilter())) {
refreshSmsItemAdapter();
}
return true;
}
public boolean onQueryTextSubmit(String query) {
LOGI("onQueryTextSubmit query='" + query + "'" +
" filter='" + getSearchFilter() + "'");
if (!equalFilters(mLastRequestedFilter, getSearchFilter())) {
refreshSmsItemAdapter();
}
return true;
}
});
updateOptionsMenu(menu);
return true;
}
示例10: setOnQueryTextListener
import android.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
public static void setOnQueryTextListener(Object searchView, Object listener) {
((SearchView) searchView).setOnQueryTextListener((OnQueryTextListener) listener);
}
示例11: onQueryTextChange
import android.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
public Disposable onQueryTextChange(final Consumer<? super String> onNext, final Consumer<? super Exception> onError, final Runnable onComplete) {
N.requireNonNull(onNext, "onNext");
N.requireNonNull(onError, "onError");
N.requireNonNull(onComplete, "onComplete");
dispatcher.append(new DispatcherBase<Object>(onError, onComplete) {
@Override
public void onNext(Object param) {
@SuppressWarnings("unchecked")
final String tmp = (String) param;
if (Fu.isUiThread()) {
onNext.accept(tmp);
} else {
UIExecutor.execute(new Runnable() {
@Override
public void run() {
onNext.accept(tmp);
}
});
}
}
});
_view.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextChange(String newText) {
dispatcher.onNext(newText);
return true;
}
@Override
public boolean onQueryTextSubmit(String query) {
// Do nothing.
return false;
}
});
disposeActions.add(new Runnable() {
@Override
public void run() {
_view.setOnQueryTextListener(null);
}
});
return this;
}
示例12: onQueryTextSubmit
import android.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
public Disposable onQueryTextSubmit(final Consumer<? super String> onNext, final Consumer<? super Exception> onError, final Runnable onComplete) {
N.requireNonNull(onNext, "onNext");
N.requireNonNull(onError, "onError");
N.requireNonNull(onComplete, "onComplete");
dispatcher.append(new DispatcherBase<Object>(onError, onComplete) {
@Override
public void onNext(Object param) {
@SuppressWarnings("unchecked")
final String tmp = (String) param;
if (Fu.isUiThread()) {
onNext.accept(tmp);
} else {
UIExecutor.execute(new Runnable() {
@Override
public void run() {
onNext.accept(tmp);
}
});
}
}
});
_view.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextChange(String newText) {
// Do nothing.
return false;
}
@Override
public boolean onQueryTextSubmit(String query) {
dispatcher.onNext(query);
return true;
}
});
disposeActions.add(new Runnable() {
@Override
public void run() {
_view.setOnQueryTextListener(null);
}
});
return this;
}
示例13: onQueryText
import android.widget.SearchView.OnQueryTextListener; //导入依赖的package包/类
public Disposable onQueryText(final OnQueryTextListener onNext) {
return onQueryText(onNext, Fu.ON_ERROR_MISSING);
}
示例14: onCreateOptionsMenu
import android.widget.SearchView.OnQueryTextListener; //导入依赖的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.friends_list, menu);
// Associate searchable configuration with the SearchView
SearchManager searchManager =
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
mSearchView =
(SearchView) menu.findItem(R.id.menuSearch).getActionView();
mSearchView.setSearchableInfo(
searchManager.getSearchableInfo(getComponentName()));
mSearchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return true;
}
@Override
public boolean onQueryTextChange(final String newText) {
LensRocketLogger.i(TAG, "Text: " + newText);
mCurrentName = newText;
mBtnAddFriend.setEnabled(true);
mBtnAddFriend.setVisibility(View.VISIBLE);
mAdapter.getFilter().filter(newText, new FilterListener() {
@Override
public void onFilterComplete(int count) {
if (mAdapter.getCount() > 0)
mLvFriends.setVisibility(View.VISIBLE);
else
mLvFriends.setVisibility(View.GONE);
if (!mCurrentName.equals("")) {
mLayoutAddFriend.setVisibility(View.VISIBLE);
} else {
mLayoutAddFriend.setVisibility(View.GONE);
}
if (mLensRocketService.getLocalFriendNames().contains(newText))
mLayoutAddFriend.setVisibility(View.GONE);
}
});
mLblNewFriendName.setText(mCurrentName);
return true;
}
});
return true;
}