I have a spinner, and I do this
public class Settings extends Activity {
String[] items = new String[] {"English", "Deutsch", "日語"};
SharedPreferences prefs;
SharedPreferences.Editor prefEditor;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.settings);
Spinner spinner = (Spinner) findViewById(R.id.spinner1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, items);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener (new OnItemSelectedListener() {
});
There's syntax error suggesting OnItemSelectedListener cannot resolved into type. The method setOnItemSelectedListener is not applicable
This is common problem on eclipse. Just add it manually:
import android.widget.AdapterView.OnItemSelectedListener;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With