Cole
Cole

Reputation: 2815

ArrayAdapter - Making a spinner?

http://developer.android.com/resources/tutorials/views/hello-spinner.html

I'm following this ^ tutorial on making a "spinner" but when I get to this code:

Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
            this, R.array.gender_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);

I get the "cannot be resolved to a type" error on:

ArrayAdapter

I'm not sure what to do here. I've done everything exactly how they said to, but I get these errors for some reason.

Upvotes: 0

Views: 1516

Answers (1)

peter.bartos
peter.bartos

Reputation: 12045

Are you not missing an import?

import android.widget.ArrayAdapter;

If you are developing in Eclipse, try a shortcut: Ctrl+Shift+O, which organizes your imports

Upvotes: 4

Related Questions