如何在搜索时去除的android搜索查看弹出的文本? [英] How to remove android searchview popup text while searching?
本文介绍了如何在搜索时去除的android搜索查看弹出的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经实现了操作栏搜索查看,它的正常工作,但在屏幕底部的浮动文本弹出窗口显示。见截图:
I have implemented action bar SearchView , it's working fine but at the bottom of the screen a floating text popup is shown. See screenshot:
ListView的Java类:
ListView Java class:
@Override
public boolean onQueryTextChange(String newText) {
if (TextUtils.isEmpty(newText)) {
mListView.clearTextFilter();
} else {
// EventAdapterView ca = (EventAdapterView)mListView.getAdapter();
// ca.getFilter().filter(newText.toString());
// Filter lFilter = mDataAdapter.getFilter();
// lFilter.filter("");
// following line was causing the ugly popup window.
mListView.setFilterText(newText.toString());
// EventAdapterView ca = (EventAdapterView)mListView.getAdapter();
// ca.getFilter().filter(newText.toString());
}
return true;
}
@Override
public boolean onQueryTextSubmit(String query) {
return true;
}
适配器类
@Override
public Filter getFilter() {
/**
* A filter object which will filter message key
* */
Filter filter = new Filter() {
@SuppressWarnings("unchecked")
@Override
protected void publishResults(CharSequence constraint,
FilterResults results) {
mEventUtil = (List<EventUtil>) results.values; // has the
// filtered
// values
notifyDataSetChanged(); // notifies the data with new filtered
// values. Only filtered values will be
// shown on the list
}
@Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults results = new FilterResults(); // Holds the
// results of a
// filtering
// operation for
// publishing
List<EventUtil> FilteredArrList = new ArrayList<EventUtil>();
if (mOriginalValues == null) {
mOriginalValues = new ArrayList<EventUtil>(mEventUtil); // mOriginalValues
}
if (mListItem == null) {
mListItem = new ArrayList<String>();
for (EventUtil message : mOriginalValues) {
mListItem.add(message.getEvent_Title());
}
}
/**
*
* If constraint(CharSequence that is received) is null returns
* the mOriginalValues(Original) values else does the Filtering
* and returns FilteredArrList(Filtered)
*
**/
if (constraint == null || constraint.length() == 0) {
/*
* CONTRACT FOR IMPLEMENTING FILTER : set the Original
* values to result which will be returned for publishing
*/
results.count = mOriginalValues.size();
results.values = mOriginalValues;
} else {
/* Do the filtering */
constraint = constraint.toString().toLowerCase();
for (int i = 0; i < mListItem.size(); i++) {
String data = mListItem.get(i);
if (data.toLowerCase().contains(constraint.toString())) {
FilteredArrList.add(mOriginalValues.get(i));
}
}
// set the Filtered result to return
results.count = FilteredArrList.size();
results.values = FilteredArrList;
}
return results;
}
};
return filter;
}
如何删除这个浮动的TextView?
How can I remove this floating TextView ?
推荐答案
试试这个
先禁用 TextFilterEnabled
在的ListView
yourListView.setTextFilterEnabled(false);
和筛选数据是这样的:
android.widget.Filter filter = yourListAdapter.getFilter();
@Override
public boolean onQueryTextChange(String newText) {
// TODO Auto-generated method stub
filter.filter(newText);
return true;
}
这就是它,去像一个魅力搜索弹出
that's it, and the search popup gone like a charm
这篇关于如何在搜索时去除的android搜索查看弹出的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文