我有一个我创建的LinkedList HashMap List<HashMap<String, String>>
,我正在尝试将它发送到我找到的自定义适配器,但它是用于Map。将它转换为接受LinkedList Hashmap的最佳方法是什么?
public class CustomListOutageAdapter extends BaseAdapter {
private final ArrayList mData;
public CustomListOutageAdapter( List<HashMap<String, String>> map) {
mData = new ArrayList();
mData.add(map);
}
@Override
public int getCount() {
return mData.size();
}
@Override
public HashMap.Entry<String, String> getItem(int position) {
return (HashMap.Entry) mData.get(position);
}
@Override
public long getItemId(int position) {
// TODO implement you own logic with ID
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final View result;
if (convertView == null) {
result = LayoutInflater.from(parent.getContext()).inflate(R.layout.mylistoutagedetails, parent, false);
} else {
result = convertView;
}
HashMap.Entry<String, String> item = getItem(position);
// TODO replace findViewById by ViewHolder
((TextView) result.findViewById(R.id.name)).setText(item.getKey());
((TextView) result.findViewById(R.id.item)).setText(item.getValue());
return result;
}
}