Android EditText 和 SearchView:主要区别是什么(设计除外)? [英] Android EditText AND SearchView : What are the main differences (except the design)?
问题描述
我需要在我的 Android 应用中实现一个搜索界面,该界面将过滤 ViewPager
中的多个 RecyclerView
.
I need to implement a search interface in my Android app that would filter several RecyclerView
inside a ViewPager
.
我已经实现了 EditText
和 SearchView
小部件并尝试查看差异.
I have already implemented both EditText
and SearchView
widgets and try to see differences.
我感兴趣的听众是:
myEditText.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
public void onTextChanged(CharSequence s, int start, int before, int count) {}
});
还有:
mySearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextChange(String newText) {
textView.setText(newText);
return true;
}
@Override
public boolean onQueryTextSubmit(String query) {
textView.setText(query);
return true;
}
我是否遗漏了一些
SearchView
允许的重要功能?EditText
没有?
Am i missing some important features that
SearchView
would allow & thatEditText
does not ?
使用这两个小部件,我是否可以使用单个搜索视图"在 ViewPager
内的 RecyclerView
之间进行搜索?
With both of these widgets, Am i able to search among RecyclerView
s inside ViewPager
with a single "search-view" ?
我不想要 ACTION_SEARCH
或任何添加的搜索对话框视图.
I don't want an ACTION_SEARCH
or any added dialog view for the search.
提前致谢!
推荐答案
Edittext
和 SearchView
的主要区别在于,您可以使用 SearchView 作为搜索工具的直接实现listView/RecyclerView
而另一方面,如果您为此使用 Edittext,则必须手动实现代码进行搜索.
Main Difference between Edittext
and SearchView
is that you can use SearchView as direct implementation for Searching facility in listView/RecyclerView
and on the other side if you use Edittext for this,you have to manually implement code for searching.
让我为您提供这两种情况的直接链接:
Let me provide you direct links for both of this scenarios :
此实现适用于 SearchView :
This implementation is for SearchView :
第二个用于 EditText :
Second one is for EditText :
如果您使用的是 searchView,请查看此链接:
If you are using searchView,also look at this link :
这将使用具有自定义实现的 RecyclerView 中的 Edittext For Search 数据.
This will use Edittext For Search data from RecyclerView with custom implementation.
现在,您必须决定哪一个更适合您,是的,请告诉我是否可以改进我的答案或者我的答案是否不清楚..
Now, you have to decide which one is more suitable for you and yes,tell me if i can improve my answer or if my answer is unclarified..
这篇关于Android EditText 和 SearchView:主要区别是什么(设计除外)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!