Add an EditText on top of your listview in its .xml layout file. And in your activity/fragment..

lv = (ListView) findViewById(;
    inputSearch = (EditText) findViewById(;

// Adding items to listview
adapter = new ArrayAdapter<String>(this, R.layout.list_item,,    products);
inputSearch.addTextChangedListener(new TextWatcher() {

    public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
        // When user changed the Text

    public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { }

    public void afterTextChanged(Editable arg0) {}

The basic here is to add an OnTextChangeListener to your edit text and inside its callback method apply filter to your listview's adapter.


To get filter to your custom BaseAdapter you"ll need to implement Filterable interface.

class CustomAdapter extends BaseAdapter implements Filterable {

    public View getView(){
    public Integer getCount()

    public Filter getFilter() {

        Filter filter = new Filter() {

            protected void publishResults(CharSequence constraint, FilterResults results) {

                arrayListNames = (List<String>) results.values;

            protected FilterResults performFiltering(CharSequence constraint) {

                FilterResults results = new FilterResults();
                ArrayList<String> FilteredArrayNames = new ArrayList<String>();

                // perform your search here using the searchConstraint String.

                constraint = constraint.toString().toLowerCase();
                for (int i = 0; i < mDatabaseOfNames.size(); i++) {
                    String dataNames = mDatabaseOfNames.get(i);
                    if (dataNames.toLowerCase().startsWith(constraint.toString()))  {

                results.count = FilteredArrayNames.size();
                results.values = FilteredArrayNames;
                Log.e("VALUES", results.values.toString());

                return results;

        return filter;

Inside performFiltering() you need to do actual comparison of the search query to values in your database. It will pass its result to publishResults() method.