1. Download our Official Android App: Forums for Android!

Apps filtrarte listview with SimpleCursorAdapter

Discussion in 'Android Development' started by soufiane.dev, May 31, 2011.

  1. soufiane.dev

    soufiane.dev Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    May 26, 2011

    May 26, 2011
    3
    0
    5
    Hi,

    I want filtrate my list view with SimpleCursorAdapter, i try this code not working

    Code (Text):
    1. public class Filtrage extends ListActivity{
    2.     DBAdapter db;
    3. @Override
    4. protected void onCreate(Bundle savedInstanceState) {
    5.     super.onCreate(savedInstanceState);
    6.     setContentView(R.layout.filtrage);
    7.     db = new DBAdapter(this);
    8.     db.open();
    9.     Cursor c2 = db.retrieveKidName();
    10.     startManagingCursor(c2);
    11.     final SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
    12.             R.layout.list_kids, c2, new String[] { DBAdapter.kid_name },
    13.             new int[] { R.id.txtKidNameList });
    14.     setListAdapter(adapter);
    15.     EditText txtFilter = (EditText) findViewById(R.id.txtFill);
    16.     txtFilter.addTextChangedListener(new TextWatcher() {
    17.         public void afterTextChanged(Editable s) {    
    18.         }
    19.  
    20.         public void beforeTextChanged(CharSequence s, int start, int count,
    21.                 int after) {
    22.         }
    23.         public void onTextChanged(CharSequence s, int start, int before,
    24.                 int count) {
    25.             if (adapter != null)
    26.                 adapter.getFilter().filter(s);
    27.     }
    28.     });
    29. }    
    30. }
     

    Advertisement

  2. soufiane.dev

    soufiane.dev Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    May 26, 2011

    May 26, 2011
    3
    0
    5
    No heeeeeeeeeeeeeeelppppp
     

Share This Page

Loading...