-1

버튼을 클릭하면 아래로 떨어지는 스피너가 있습니다. 그러나 onItemSelectedListener를 설정하려고 할 때 click 이벤트를 사용하지 않습니다.Spinner on Button이 클릭 이벤트에 응답하지 않음 :

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

코드를 게시하십시오. –

+0

코드에서 아무 것도 할 수 없습니다. –

+0

열리는 의미는 ..... ..... –

답변

0

는 모든 View는 (당신이 Button 원하는 View없이 행동을 할 수 있습니다)에 android:clickable 속성을 지원합니다. android : focusable도 있습니다.

+0

spinner.performClick();을 사용했습니다. 버튼 –

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()); 
      } 
     }); 
+0

의 클릭 이벤트에서 OnItemClickListener를 회 전자에 설정할 수 없습니다. –

관련 문제