まず私の英語でごめんなさい
この問題に対する多くの回答を読みましたが、コードを実行する方法がわかりません。
上記の EditText のテキストで listView をフィルタリングしたいと思います。
ここに私のコードがあります:
private DbAdapter mDbHelper;
private EditText mSearch;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.baes_bat_list);
setTitle(R.string.baes_list_title);
mDbHelper = new DbAdapter(this);
mDbHelper.open();
fillData();
registerForContextMenu(getListView());
mSearch = (EditText) findViewById(R.id.searchbox);
}
private void fillData() {
String search = "";
search = mSearch.getText().toString();
// Get all of the rows from the database and create the item list
Cursor baesCursor = mDbHelper.fetchAllBaes(search);
startManagingCursor(baesCursor);
// Create an array to specify the fields we want to display in the list (only TITLE)
String[] from = new String[]{DbAdapter.BAES_NOM, DbAdapter.BAES_BAT};
// and an array of the fields we want to bind those fields to (in this case just text1)
int[] to = new int[]{R.id.text1, R.id.text2};
// Now create a simple cursor adapter and set it to display
// Now create a simple cursor adapter and set it to display
SimpleCursorAdapter baes =
new SimpleCursorAdapter(this, R.layout.baes_row, baesCursor, from, to);
setListAdapter(baes);
};
ここに私のDBアダプターがあります
public Cursor fetchAllBaes(String string) {
String [] columns=new String[]{BAES_ID +" as _id",BAES_NOM,BAES_BAT,BAES_LOC,BAES_MISESERVICE,BAES_COUP,BAES_DATE_VISITE,BAES_ETAT, BAES_SYNC};
String [] search = null;
return mDb.query(TABLE_BAES, columns, BAES_BAT + "= ?", search, null, null, null);
}
私は一歩を逃したと思いますが、どれがわかりません。ご協力ありがとうございました。