-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyListAdapter.java
More file actions
64 lines (49 loc) · 1.7 KB
/
MyListAdapter.java
File metadata and controls
64 lines (49 loc) · 1.7 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.jose.saneesh.jsonparsing;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Created by Saneesh on 6/26/2018.
*/
class MyListAdapter extends BaseAdapter {
private static List<DataFields> list = Collections.emptyList();
// List<DataFields> list1 = Collections.emptyList();
private LayoutInflater layoutInflater;
Context c;
MyListAdapter(Context context, List<DataFields> list) {
c = context;
layoutInflater = LayoutInflater.from(context);
this.list = list;
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
return list.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater layoutInflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row = layoutInflater.inflate(R.layout.row_layout, parent, false);
TextView name = (TextView) row.findViewById((R.id.name));
TextView description = (TextView) row.findViewById((R.id.description));
TextView url = row.findViewById(R.id.url);
DataFields tmp = list.get(position);
name.setText(tmp.name);
description.setText(tmp.description);
url.setText(tmp.url);
return row;
}
}