Casting spinners in android

I am currently trying to use various google android examples at http://developer.android.com/guide/tutorials/views/hello-spinner.html

BUT I cannot get this part to work, although the code is exactly the same as the one presented on the website.

Spinner s = (Spinner) findViewById (R.id.spinner);

Eclipse continues to say: โ€œCannot be dropped from View to Spinnerโ€

Do any of you guys know how to solve this?

Thanks.

+3
source share
4 answers

Are you sure you imported android.widget.Spinner, and not something else called the same? Perhaps try the following to be sure:

android.widget.Spinner s = (android.widget.Spinner) findViewById(R.id.spinner);

, , .

+4

, , android.widget.Spinner? Spinner View, .

+1

, . , - Foo<Spinner> Foo<A>, Spinner . generic Foo<A>, Spinner .

( String, Spinner, )

+1

spinner .

+1

Source: https://habr.com/ru/post/1717901/


All Articles