Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Custom Search in ListView

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 643
    Comment on it

    In OnCreate() Method add addTextChangedListener(new TextWatcher() to an EditText View

    example:

    1. searchEditText.addTextChangedListener(new TextWatcher() {
    2. @Override
    3. public void onTextChanged(CharSequence s, int start, int before,
    4. int count) { }
    5.  
    6. @Override
    7. public void beforeTextChanged(CharSequence s, int start, int count,
    8. int after) {
    9. // TODO Auto-generated method stub
    10. }
    11.  
    12. @Override
    13. public void afterTextChanged(Editable s) {
    14. System.out.println("in Add text change Listner afterText change "+s);
    15. searchLocation(s.toString());
    16. }
    17. });

    Use Custom adapter to Set the ListView. By using on listview.setAdapter(adapter);

    Create a Function for search list:

    public void searchLocation(String search) { SEARCH_DATA.clear();
    int c=0; for(int i=0;i

    1. SEARCH_DATA.add(holder);
    2. System.out.println("Name searched ::"+SEARCH_DATA.get(c).getName());
    3. c++;
    4. //favArray[i]=DATA.get(i).name+" "+DATA.get(i).number;
    5. }
    6. }
    7.  
    8. adapter.notifyDataSetChanged();
    9. //adapter.notifyDataSetInvalidated();
    10. //setupLocationListView.invalidate();
    11. }

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: