//在按鈕點擊事件裡處理
bt_search.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
String strSearch = ed_input.getText().toString();
SQLiteDatabase db = VSmsDBUtil.createOrOpenDatabase();
LogWrapper.i("search", "db = "+db);
Cursor cursor =
db.rawQuery("SELECT sTitle, sContent, sTime, sImage FROM msgtab where ( findItem like ?)",
new String[]{"%"+strSearch+"%"});
tempListSms = new ArrayList<TestSmsBean>();
if( cursor != null ){
if( cursor.moveToFirst() ){
do{
TestSmsBean tsb = new TestSmsBean(
cursor.getString(0),
cursor.getString(1),
cursor.getString(2),
cursor.getString(3));
tempListSms.add(tsb);
}while( cursor.moveToNext());
}
adapter.assignment(tempListSms);
listView.setAdapter(adapter);
adapter.notifyDataSetChanged();
}else{
Toast.makeText(getApplicationContext(), "對不起,沒找到匹配的結果", Toast.LENGTH_LONG).show();
}
cursor.close();
db.close();
//ed_input是EditTextView
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (!ed_input.isFocusable()) {
// searchauto.setInputType(InputType.TYPE_NULL);
// imm.showSoftInputFromInputMethod(AutoCompleteTextView_testActivity.this.getCurrentFocus()
// .getWindowToken(), 0);
imm.showSoftInputFromInputMethod(ed_input.getWindowToken(),
0);
LogWrapper.i("vvvv","ed_input,hasFocus true");
isFresh = false;
} else {
try {
// imm.hideSoftInputFromWindow(AutoCompleteTextView_testActivity.this.getCurrentFocus().getWindowToken()
// , 0);
imm.hideSoftInputFromWindow(ed_input.getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
LogWrapper.i("vvvv","ed_input,hasFocus false");
isFresh = true;
} catch (Exception e) {
}
}
}
});
}