我想實現的功能是當選擇自動完成文本框的某一項時,添加的監聽器就會有反應。用如下代碼沒有實現,請高人指點問題出現在哪裡。程序中的PhoneName是自動完成文本框的名稱。
PhoneName.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
Toast.makeText(check.this," selected", Toast.LENGTH_LONG).show();
}
public void onNothingSelected(AdapterView<?> arg0) {
}
}
我之前用這段代碼實現了這個功能:
phoneName.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View arg1, int pos,
long id) {
Toast.makeText(check.this," selected", Toast.LENGTH_LONG).show();
}
}