我正在尝试为授权活动编写代码。当我在 inputEmail 中输入一些条目时,我希望如果存在相应的记录,我的 inputPasword 将自动归档。但是 onItemSelectedListener 似乎不起作用。当我选择项目时没有任何反应。日志不火到。我想知道我是否犯了一些错误,或者我走错了路。
AutoCompleteTextView inputEmail;
inputEmail = (AutoCompleteTextView) findViewById(R.id.loginEmail);
inputEmail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Set<String> keys = prefs.getAll().keySet();
emails.clear();
if (keys.size() != 0) {
emails.addAll(keys);
} else
emails.add("");
inputEmail.setAdapter(adapter);
email = inputEmail.getText().toString();
}
});
inputEmail.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
email = inputEmail.getText().toString();
password = prefs.getString(email, "");
Log.d(email + " "+password, "email+password");
if (password.length() > 1) {
inputPassword.setText(password);
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});