Maram Wat
Maram Wat

Reputation: 17

error in create object of class

I have my Spinner which is an object of the class SpinnerAdapter. I try to create the object but there is an errors I try to solve it but I can not.

Here is a picture of error that happened:

enter image description here

Upvotes: 1

Views: 116

Answers (5)

Vincent Mimoun-Prat
Vincent Mimoun-Prat

Reputation: 28541

A shortcut that will save you time : CTRL + SHIFT + O in Eclipse (will organize the imports of the current file in the editor). Try it and see what else needs to be fixed in your code.

A combo I like instead of doing a save (real fast to type when you're used to it):

  • CTRL + SHIFT + O : organize imports
  • CTRL + SHIFT + F : format code
  • CTRL + SHIFT + S : save all opened files

Upvotes: 0

boiledwater
boiledwater

Reputation: 10482

import android.widget.AdapterView.OnItemSelectedListener;

Please check above import.

Upvotes: 0

stealthjong
stealthjong

Reputation: 11093

Either delete the import android.widget.SpinnerAdapter, or change your Classname to something like CustomAdapter (and you'll see that the instantiated object will just remain an interface (which should be your concrete class), so change that as well)

Upvotes: 1

Paul-Jan
Paul-Jan

Reputation: 17278

Your code has a naming conflict with the standard Android interface SpinnerAdapter. To make sure your own class SpinnerAdapter is used, make sure to prefix it with the full package name. Getting rid of the android.widget.SpinnerAdapter import should work too.

To avoid any and all confusion, you might want to simply change the name of your own adapter.

Upvotes: 0

Egor
Egor

Reputation: 40203

Your code fails to compile simply because SpinnerAdapter is an interface, and as you know, you can't instantiate an interface. You should use one of the classes that implement SpinnerAdapter. You can find more information in the documentation. Hope this helps.

Upvotes: 0

Related Questions