对AutoCompleteTextView添加text变化的监听函数:
mAutoCompleteTextView.addTextChangedListener(new TextWatcher(){
@Override
public void afterTextChanged(Editable s) {
// 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 onTextChanged(CharSequence s, int start, int before,
int count) {
// TODO Auto-generated method stub
if(s.toString().length()>0){
/**电话本列表背景置灰切不可点击。*/
m_list_frame_book.setEnabled(false);
m_list_frame_book.setBackgroundColor(0x7DC0C0C0);
}else{
/**点击后是listview的灰显消失,listview也可以点击。*/
m_list_frame_book.setEnabled(true);
m_list_frame_book.setBackgroundDrawable(null);
}
String mSearchaContactName = s.toString().trim();
Cursor cursor = DBHelper.QueryContact(mSearchaContactName);
//startManagingCursor(cursor);
SearchCurAdapter adapter = new SearchCurAdapter(CarBTActivity.this,cursor,true);
mSearchPhoneBook.setAdapter(adapter);
}
});
对AutoCompleteTextView下来框添加点击事件处理:
mAutoCompleteTextView.setOnItemClickListener(searchItemClick);
/**
* 搜索联系人下拉框点击事件
*/
OnItemClickListener searchItemClick=new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> av, View v, int position,
long l) {
// TODO Auto-generated method stub
m_show_mode=7;
changeBTFrameShow();
changeBottomBnFocus(R.id.id_bn_keyboard);
//View mView = av.getChildAt(position);
TextView tvName= (TextView) v.findViewById(R.id.search_connact_name);
TextView tvNum=(TextView)v.findViewById(R.id.search_connact_num);
String selectName=tvName.getText().toString();
String selectNum=tvNum.getText().toString();
Message localMessage = new Message();
localMessage.obj = selectNum;
localMessage.what = BTSdevice.OPER_BTORDERDIAL;
if (mBTActionHandle.hasMessages(BTSdevice.OPER_BTORDERDIAL)){
mBTActionHandle.removeMessages(BTSdevice.OPER_BTORDERDIAL, selectNum);
}
mBTActionHandle.sendMessageDelayed(localMessage, 1000L);
connecting_keyboard_phone_num.setText(selectNum);
m_talking_keyboard_phone_num_d.setText(selectNum);
m_talking_keyboard_phone_num.setText(selectNum);
connecting_keyboard_phone_name.setText(selectName);
m_talking_keyboard_phone_name_d.setText(selectName);
m_talking_keyboard_phone_name.setText(selectName);
m_handle_talking.sendEmptyMessageDelayed(0, 10000L);
//int position=0;
Log.v(TAG,"==========>item click in");
mSearchPhoneBook.setText(null);
mSearchPhoneMiss.setText(null);
mSearchPhoneIn.setText(null);
mSearchPhoneOut.setText(null);
/**点击后是listview的灰显消失,listview也可以点击。*/
m_list_frame_book.setEnabled(true);
m_list_frame_book.setBackgroundDrawable(null);
}
};