Long click to remove suggestion

This commit is contained in:
seven332 committed 2016-02-20 12:59:20 +08:00
1 parent 64e22ade37
commit 2f3ab8d244
1 file changed
+10
@@ -148,6 +148,16 @@ public class SearchBar extends FrameLayout implements View.OnClickListener,
mEditText.setSelection(mEditText.getText().length());
}
});
mList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
String suggestion = mSuggestionList.get(MathUtils.clamp(
position - mList.getHeaderViewsCount(), 0, mSuggestionList.size() - 1));
mSearchDatabase.deleteQuery(suggestion);
updateSuggestions();
return true;
}
});
}
private void addListHeader() {