listView에서 제품 이름을 검색하려고하지만 검색 텍스트 필드의 일부 텍스트를 입력 한 후에 아무 것도 표시되지 않습니다. ArrayAdapter를 사용하지 않지만 ResourceCursorAdapter를 사용하고 있습니다.listView의 검색 기능
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
helper = new ComicsData(this);
helper.open();
listSearch=(EditText)findViewById(R.id.inputSearch);
listSearch.addTextChangedListener(filterTextWatcher);
model = helper.getAllProduct(list);
startManagingCursor(model);
adapter=new ShoppingListAdapter(this, model);
listView.setAdapter(adapter);
}
private TextWatcher filterTextWatcher=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) {
//String search=listSearch.getText().toString();
//int textLength=search.length();
adapter.getFilter().filter(s);
}
};
ShoppingListAdapter
class ShoppingListAdapter extends ResourceCursorAdapter {
private final String CN = null;
public ShoppingListAdapter(Context context, Cursor c) {
super(context, R.layout.productrow, c);
// TODO Auto-generated constructor stub
}
@Override
public void bindView(View row, Context context, Cursor c) {
// TODO Auto-generated method stub
listName = (TextView) row.findViewById(R.id.produtName);
listName.setText(helper.getProductName(c));
누구 내 실수를 알아?
내 검색어 부분에 LIKE 문을 사용해야합니까? – johnk
@johnk 나는 그렇다고 생각한다. 도움을 청하는 –
... 나는 개념을 얻었 .. – johnk