• 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
Dec 7, 2017
9
0
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.
 
Upvote 0
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.
 
  • Like
Reactions: AcinShn
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones