zarabela
دوشنبه 12 مرداد 1394, 10:51 صبح
سلام
من برای جستجو از کد زیر استفاده کردم
final EditText et=(EditText)findViewById(R.id.eDitText1);
et.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
db.findBeyt(et.getText().toString(),tbl_beyt);
tazeSazi();
}
});
public void tazeSazi() {
ArrayAdapter<Beyt> adapter;
adapter=new ArrayAdapter<Beyt>(this,
android.R.layout.simple_list_item_1, beyTha);
setListAdapter(adapter);
}
findBeyt:
public List<Beyt> findBeyt(String beyt,String tabale) throws SQLException
{
Cursor cursor =
db.query(true, tabale, new String[] {KEY_ROWID,
KEY_BEYT}, KEY_BEYT + " LIKE '%" + beyt + "%'", null,
null, null, null, null);
List<Beyt> beytha = cursorToList(cursor);
return beytha;
}
ولی وقتی داخل editText چیزی تایپ میکنم این ارور رو میده:
??-?? ??:??:??.???: INFO/<unknown>(<unknown>): java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/data/com.example.data/databases/laki
مشکل کار چیه؟
من برای جستجو از کد زیر استفاده کردم
final EditText et=(EditText)findViewById(R.id.eDitText1);
et.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
db.findBeyt(et.getText().toString(),tbl_beyt);
tazeSazi();
}
});
public void tazeSazi() {
ArrayAdapter<Beyt> adapter;
adapter=new ArrayAdapter<Beyt>(this,
android.R.layout.simple_list_item_1, beyTha);
setListAdapter(adapter);
}
findBeyt:
public List<Beyt> findBeyt(String beyt,String tabale) throws SQLException
{
Cursor cursor =
db.query(true, tabale, new String[] {KEY_ROWID,
KEY_BEYT}, KEY_BEYT + " LIKE '%" + beyt + "%'", null,
null, null, null, null);
List<Beyt> beytha = cursorToList(cursor);
return beytha;
}
ولی وقتی داخل editText چیزی تایپ میکنم این ارور رو میده:
??-?? ??:??:??.???: INFO/<unknown>(<unknown>): java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/data/com.example.data/databases/laki
مشکل کار چیه؟