• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Customize ArrayAdapter for HashMap

AcinShn

Lurker
Need some help plugging ListView into customized ArrayAdapter, where the datasource is a HashMap<String, String> pair from JSON
Possibly an incompatibility between the way it is defined in MainActivity.java and the customized MastbeckenAdapter.java

ERROR: MastbeckenAdapter cannot be applied to ArrayList<HashMap<String, String>>
 
Last edited:
You get the error because your adapter class has the following constructor signature

Code:
public MastbeckenAdapter(Context context, ArrayList<Mastbecken> mastbeckens)

But the second parameter you're passing in when you create an instance of this class, is of type

Code:
ArrayList<HashMap<String, String>> mastbeckenList;

You'll have to change either the constructor declaration, or the type of parameter you pass in to the constructor.
 
This is the problem with coding by numbers. If you don't have an understanding of the basic concepts, you're going to run into trouble.
If you don't understand my explanation above, then you need to spend some time learning the Java programming language. Sorry to be brutal, but you cannot hope to write an app without understanding the basics.

Let me ask you this. Can you explain in English, what this type declaration means?

Code:
ArrayList<HashMap<String, String>> mastbeckenList;

And if your explanation doesn't include the word "Generic", then step away from the keyboard, and pick up a good beginner's book on Java.
 
All done, finished. Just a bit more effort and trial and error got me over finish line
Deleted thread so as not to annoy further.
 
Well done. Glad you got it all sorted.
No annoyance caused in the slightest.
 
Back
Top Bottom