#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2016
    Posts
    2
    Rep Power
    0

    Search in item and subitem and displey only one item


    Hi, i create app where user can search in items. I use for display SimpleAdapter with item and subitem. Problem is in filtering. Searching is used in item and subitem. It's right but when searching word is contained in item and subitem simultaneously, I see 2 results although it's one item actually.
    Code:
    static ListView listview;
    static SearchView searchview;
    public android.widget.Filter filter;
    
    protected void onCreate(Bundle savedInstanceState) {
    ...
    searchview = (SearchView) findViewById(R.id.searchView);
    searchview.setOnQueryTextListener(this);
    
    listview = (ListView) findViewById(R.id.listView);
    registerForContextMenu(listview);
    arrayadapter = new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, listSearch);
    listview.setTextFilterEnabled(true);
    ...​
    }
    
    public boolean onQueryTextChange(String newText) {
    if (TextUtils.isEmpty(newText)) {
    listview.clearTextFilter();​
    } else {
    filter.filter(newText);​
    }
    return true;​
    }
    
    public boolean onQueryTextSubmit(String query) {
    return false;​
    }
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2016
    Posts
    2
    Rep Power
    0

IMN logo majestic logo threadwatch logo seochat tools logo