Could not find class 'android.widget.ThemedSpinnerAdapter'
Asked Answered
T

4

15

I have ,in a fragment, a method call who open an AlertDialog when an user tap on an button, in that dialog I would like to show a Spinner with countries ( Spain, Italy, French....)

My code for the spinner is the following:

RestCountries restCountries = new RestCountries();
    List<RestCountries.Datum>  countries = restCountries.data;
    String mCities ="";
    ArrayList<String> citiesArrayList = new ArrayList<>();

    for(RestCountries.Datum data : countries){
        mCities = data.name;
        citiesArrayList.add(mCities);
    }

    ArrayAdapter spinnerAdapter = new ArrayAdapter(getActivity(),android.R.layout.simple_spinner_dropdown_item,  citiesArrayList );
    mCountrySpinner.setAdapter(spinnerAdapter);

The spinner is showed emphy after the dialog is opened.

On the logcat I get

Could not find class 'android.widget.ThemedSpinnerAdapter', referenced
from method
android.support.v7.widget.AppCompatSpinner$DropDownAdapter.<init>

Any idea about what I am doing wrong

Tenderloin answered 29/10, 2015 at 14:16 Comment(8)
are you using a device or an emulator?Jude
which version does it use? API 23/ Marshmallow?Jude
Yes it is correct API 23/ MarshmallowTenderloin
according to [this link, especially inner class DropDownAdapter] (android.googlesource.com/platform/frameworks/support/+/080abff/…) the error happens while the constructor for the DropDownAdapter is executed ('IS_AT_LEAST_M' is true for your device). BUT then the runtime should be able to find 'android.widget.ThemedSpinnerAdapter' on a Marshmallow device. Maybe the problem is similar to this SO question which means you should check all your dependencies/ build filesJude
Thanks for letting me know :) Maybe you could write (as an answer) which IDE you work with and what you had to do to solve the problem. Especially if you're working with Android Studio - it is not really well documented, so a good answer here could save other developers lots of time.Jude
I had this exactly problem and the link solved my problem too. I am still using Eclipse and I had to check the android 6.0 under the export Tab but it didn-t worked till I put it top, as suggested on the linked SO question.Carnation
Don't know how to fix this with Android Studio. Any idea?Rattlebrain
@JanineKroser are you sure the array you are passing has elements? I mean ArrayAdapter spinnerAdapter = new ArrayAdapter(context,android.R.layout.simple_spinner_dropdown_item, citiesArrayList ); citiesArrayList needs to have elements and its size should be >0Tenderloin
G
1

In my case I solved the problem just setting for all the modules in the project the same SDKCompileVersion. Here it is my complete answer in a similar question

Cheers

Could not find class 'android.widget.ThemedSpinnerAdapter' [Android Studio]

Grallatorial answered 1/4, 2016 at 8:41 Comment(0)
P
0

I faced and win this problem!

In case if you are using AndriodAnnotations here the problem is that I filled the lists in the method onCreate(). I used to get View via findViewById(R.id...) and worked with them.

Now, as it turned out during debugging, all Views is not created in onCreate() yet! The problem was solved when I found an annotation @AfterViews in the docs, and the method under this annotation now fills all my actions and does initialization of fields.

So, anyway, check your code on NullPointerException caused by invoking empty view object.

Perorate answered 27/10, 2016 at 6:29 Comment(0)
P
0

This may not help everyone, but I was having this issue trying to add a spinner to a PopupWindow.

I updated my compileSdkTarget from 23 to 25, and my support library version to 25.1.0, but it didn't help.

It turned out that changing the spinnerMode to "dialog" worked round the problem:

<Spinner
 android:id="@+id/group_spinner"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:spinnerMode="dialog"
/>

It doesn't completely fix it of course if you really want a dropdown spinner.

Ply answered 22/12, 2016 at 14:19 Comment(0)
Q
-2

There are several different causes of this problem. In my case (was trying to sign up to Parse), I got this error trying the app on a tablet.When I switched to an Android phone, I got the error message:

You must register this ParseObject subclass before instantiating it

So, In my App.java class I did this:

public class App extends Application {


public void onCreate() {
    super.onCreate();
    Parse.enableLocalDatastore(this);
    Parse.initialize(this, "PARSE APPLICATION ID", "PARSE CLIENT KEY");
}
}

and then in my manifest, I did this:

<application
    android:name=".App"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    ...

That was it.Had nothing to do with Spinner

Quarles answered 23/1, 2016 at 21:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.