我有一个微调器,当单击一个按钮时它会下降。但是当我尝试设置onItemSelectedListener时,它没有接受click事件。
spnrLocation.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View arg1,
int arg2, long arg3) {
System.out.println("location clicked" + arg2);
edtLocation.setText(parent.getItemAtPosition(arg2).toString());
System.out.println("wfefe"
+ parent.getItemAtPosition(arg2).toString());
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
答案 0 :(得分:1)
// try this
spnrLocation.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
System.out.println("location clicked" + i);
edtLocation.setText(spnrLocation.getSelectedItem().toString());
System.out.println("wfefe"
+ spnrLocation.getSelectedItem().toString());
}
});
答案 1 :(得分:0)
任何View
支持android:clickable属性(允许您将View
表现为Button
)。
还有android:focusable。