-1

我有一个微调器,当单击按钮时它会下降。但是当我试图设置 onItemSelectedListener 时,它并没有接受点击事件。

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) {
            }
        });
4

2 回答 2

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());
            }
        });
于 2013-10-23T09:02:20.240 回答
0

AnyView支持android:clickable属性(它可以让任何View行为都像 a Button)。还有android:focusable。

于 2013-10-23T08:51:31.020 回答