1

ArrayList<HashMap<String, ?>>  list;
f(!list.isEmpty()){

          adapter = new MySimpleArrayAdapter(getActivity(),R.layout.inner_base_header_cutom, list);
          listview.setAdapter(adapter);
          Log.i("LIST Active", "LIST Active" + list.size());
      }

public class MySimpleArrayAdapter extends ArrayAdapter<ArrayList<HashMap<String, ?>>> {
          private final Context context;
          private final ArrayList<HashMap<String, ?>> values;

          public MySimpleArrayAdapter(Context context, int innerBaseHeaderCutom, ArrayList<HashMap<String, ?>> list) {
            super(context, innerBaseHeaderCutom, list);
            this.context = context;
            this.values = list;
          }

}


ERROR:

The constructor ArrayAdapter<ArrayList<HashMap<String,?>>>(Context, int, ArrayList<HashMap<String,?>>) is undefined

Also Cannot Remove ListView:

remove(list.get(position));

Error:

The method remove(ArrayList<HashMap<String,?>>) in the type ArrayAdapter<ArrayList<HashMap<String,?>>> is not applicable for the arguments (HashMap<String,capture#2-of ?>)
4
  • What is list in your code? Commented Mar 7, 2014 at 7:18
  • ` ArrayList<HashMap<String, ?>>`, I added some does above. Commented Mar 7, 2014 at 7:19
  • ArrayList<HashMap<String, ?>> list why the ?. They value is not a string?. Also where do you populate the list Commented Mar 7, 2014 at 7:20
  • Maybe try using List instead ArrayList ? Commented Mar 7, 2014 at 7:25

2 Answers 2

1

Just strip the last argument when you call the constructor of the super class

super(context, innerBaseHeaderCutom);

EDIT:
Another think you can try is changing this:

public class MySimpleArrayAdapter extends ArrayAdapter<ArrayList<HashMap<String, ?>>> {

for

public class MySimpleArrayAdapter extends ArrayAdapter<HashMap<String, ?>> {

And do the same change in the constructor.

Sign up to request clarification or add additional context in comments.

2 Comments

how will the adapter know many list should be populated sir. still not populating I check the list.size and I got three.
Because the ArrayAdpater expects you to pass the type of objects that you will have in your Array, not the structure holding those objects (which is the ArrayList).
0
You are creating ArrayList with ArrayList<HashMap<String, ?>> instead you can try ArrayList<HashMap<String, ? extends Object>>

Check the sample code and output.

public class MyJavaTesting{
public MyJavaTesting(ArrayList<HashMap<String, ? extends Object>> list) {
    System.out.println(list);
}

public static void main(String[] args) {
    ArrayList<HashMap<String, ? extends Object>> list = new ArrayList<HashMap<String,?>>();
    HashMap<String, String> map1 = new HashMap<String, String>();
    map1.put("Key", "value");
    list.add(map1);

    HashMap<String, Object> map2 = new HashMap<String, Object>();
    map2.put("Key", new Object());
    list.add(map2);

    MyJavaTesting manager = new MyJavaTesting(list);
}
}

Output: [{Key=value}, {Key=java.lang.Object@4f1d0d}]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.