Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spinner error on SetOnItemSelectedListener

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

like image 243
jason hong Avatar asked Jan 17 '12 02:01

jason hong


1 Answers

This is common problem on eclipse. Just add it manually:

import android.widget.AdapterView.OnItemSelectedListener;
like image 114
ariefbayu Avatar answered Sep 27 '22 01:09

ariefbayu