2016-05-16 10 views

答えて

2

これを試してください!

spin.setOnItemSelectedListener(new OnItemSelectedListener() { 

     @Override 
     public void onItemSelected(AdapterView<?> arg0, View arg1, 
       int arg2, long arg3) { 
      String yourName=spiner.getSelectedItem().toString(); 

     } 

     @Override 
     public void onNothingSelected(AdapterView<?> arg0) { 
      // TODO Auto-generated method stub 

     } 
    }); 

上記のコードが役に立たない場合は、これを試して!!

Spinner spinner = (Spinner)findViewById(R.id.spinner); 
String text = spinner.getSelectedItem().toString(); 
0

Javaでは、JComboBoxを使用してリスト項目を表示し、選択することができます。 例:

String[] numbers= { "One", "Two", "Three", "Four", "Five" }; 
//Create the combo box, select item at index 4. 
//Indices start at 0, so 4 specifies the 'Five'. 
JComboBox clst= new JComboBox(numbers); 
petList.setSelectedIndex(4); 
petList.addActionListener(this); 
関連する問題