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
也无法删除ListView:
remove(list.get(position));
错误:
The method remove(ArrayList<HashMap<String,?>>) in the type ArrayAdapter<ArrayList<HashMap<String,?>>> is not applicable for the arguments (HashMap<String,capture#2-of ?>)
答案 0 :(得分:1)
当你调用超类
的构造函数时,只需删除最后一个参数super(context, innerBaseHeaderCutom);
编辑:
另一个人认为你可以尝试改变这个:
public class MySimpleArrayAdapter extends ArrayAdapter<ArrayList<HashMap<String, ?>>> {
代表
public class MySimpleArrayAdapter extends ArrayAdapter<HashMap<String, ?>> {
在构造函数中进行相同的更改。
答案 1 :(得分:0)
You are creating ArrayList with ArrayList<HashMap<String, ?>> instead you can try ArrayList<HashMap<String, ? extends Object>>
检查示例代码和输出。
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);
}
}
<强>输出:强> [{Key = value},{Key = java.lang.Object @ 4f1d0d}]