miteshpithadiya / SearchableSpinner

Spinner with searchable items.
672 stars 244 forks source link

When the listview dialog is opened and I press the home button, the app crashes. How can I fix that? #84

Open muhammadimran021 opened 6 years ago

VerumCH commented 6 years ago

I noticed the same issue. Also happens when hitting the "recent apps" button. Interestingly, does not happen on orientation change. The cause (when I encountered it) is thus:

java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.toptoche.searchablespinnerlibrary.SearchableSpinner)

which is in turn caused by, in my case:

Caused by: java.io.NotSerializableException: android.widget.ArrayAdapter

So the issue seems to be attempting to serialize the adapter attached to the "Spinner," if said adapter is not serializable. Without changing the source code of the project, the only fixes off the top of my head are:

A pain? Yes, and so I personally will probably look for another solution unless this (and other things) are fixed.

If you simply need a general (no specific details) Searchable Spinner implementation, I also found this one:

https://github.com/michaelprimez/searchablespinner

This one requires (currently) targeting API 21+, however.

vedprakashwagh commented 5 years ago

I encountered this error in my app, but I solved this by looking at the error. I'll tell you the solution to the problem in short. I was using ArrayAdapter in following way ArrayAdapter adapter = new ArrayAdapter(context, android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.whatever)); to display spinner items, but while initializing ArrayAdapter, you can see I made an unchecked call there, so my app crashed when it was minimized. So what I changed in this code was adding concrete type to the object by modifying it in following way ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.whatever)); Now, as my spinner only contained Strings, I could pass String there, but, depending on the layout you'll be submitting to the spinner(if you're using custom views) you can pass your POJO class there.