私はListViewとEditTextを持っています。 EditTextで入力する際にListViewデータをフィルタリングするにはどうすればよいですか?androidでEditTextを入力するときにListViewデータをフィルタする方法
私のコードは以下の通りです:クラスListContacts
public class ImageCursorAdapter extends SimpleCursorAdapter {
private Cursor c;
private Context context;
public ImageCursorAdapter(Context context, int layout, Cursor c,
String[] from, int[] to) {
super(context, layout, c, from, to);
this.c = c;
this.context = context;
}
public View getView(int pos, View inView, ViewGroup parent) {
}
}の
public class ListContacts extends ListActivity {
ListAdapter lAdapter;
EditText filterText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Associate the xml with the activity
setContentView(R.layout.activitylist);
Cursor cursor = getContentResolver().query(
ContactsContract.Contacts.CONTENT_URI, null,
null, null,
null);
startManagingCursor(cursor);
// start mappings
String[] columns = new String[] { ContactsContract.Contacts.DISPLAY_NAME };
int[] names = new int[] { R.id.contact_name };
lAdapter = new ImageCursorAdapter(this, R.layout.main, cursor, columns,
names);
/** *連絡先をフィルタリングする */
filterText = (EditText) findViewById(R.id.EditText01);
filterText.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) {
}
});
}
} //終了// ImageCursorAdapterの終わり
sample.Hereアレイアダプタのおかげでlsitviewを設定するために使用されます。ここで私はListAdapterを使用しています...私に別の解決策を教えてください。 – jennifer
あなたが提供したリンクは壊れています。もう一度投稿してもいいですが、同じ問題はありませんが、あなたの答えはここからリンクされています[http://stackoverflow.com/questions/4711459/sorting-data-in-autocompletetextview] – madcoderz
@madcoderzリンクを確認してください – ingsaurabh