Jump to content

filter d'un list avec un textwatcher


soufiane.dev

Recommended Posts

Salut,

je ve faire une list filtrable par un textedit mais ce code ça marche pas

Cursor c2 = db.vaccinchild();
	startManagingCursor(c2);
	final SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
			R.layout.vaccinlist, c2, new String[] { DBAdapter.doctor,
					DBAdapter.child_name, DBAdapter.date_received },
			new int[] { R.id.txtvaccin, R.id.txtchild, R.id.txtdate });
	setListAdapter(adapter);
	EditText txtFilter = (EditText) findViewById(R.id.txtsearch);
	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) {
			adapter.getFilter().filter(s);
	}
	});

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...