按钮上的微调器点击不响应Click事件:

时间:2013-10-23 08:47:36

标签: android spinner android-spinner android-button onitemclicklistener

我有一个微调器,当单击一个按钮时它会下降。但是当我尝试设置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) {
            }
        });

2 个答案:

答案 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。