-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMySimpleAdapter.java
More file actions
36 lines (29 loc) · 927 Bytes
/
Copy pathMySimpleAdapter.java
File metadata and controls
36 lines (29 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.example.jsonlistview;
import java.util.ArrayList;
import java.util.HashMap;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SimpleAdapter;
import android.widget.TextView;
public class MySimpleAdapter extends SimpleAdapter {
private ArrayList<HashMap<String, String>> results;
private Context context;
public MySimpleAdapter(Context context,
ArrayList<HashMap<String, String>> data, int resource,
String[] from, int[] to) {
super(context, data, resource, from, to);
this.results = data;
}
@Override
public View getView(int position, View view, ViewGroup parent) {
View v = view;
if (v == null) {
LayoutInflater inflater = (LayoutInflater) parent.getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.list_item, null);
}
return v;
}
}