soufiane.dev Posted May 31, 2011 Share Posted May 31, 2011 Salut, Je veux filtrer une list avec SimpleCursorAdapter, voila mon code public class Filtrage extends ListActivity{ DBAdapter db; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.filtrage); db = new DBAdapter(this); db.open(); Cursor c2 = db.retrieveKidName(); startManagingCursor(c2); final SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.list_kids, c2, new String[] { DBAdapter.kid_name }, new int[] { R.id.txtKidNameList }); setListAdapter(adapter); EditText txtFilter = (EditText) findViewById(R.id.txtFill); txtFilter.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { if (adapter != null) adapter.getFilter().filter(s); } }); } } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.