-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomFound
98 lines (82 loc) · 2.84 KB
/
CustomFound
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package com.example.bilkentcompanion;
import android.app.Activity;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
public class CustomFound extends ArrayAdapter<String> {
private String[] itemNames;
private String[] desc;
private String[] dates;
//private Integer[] imgId;
private Activity context;
private String[] uids;
//public Custom(Activity context, String[] itemNames, String[] desc, Integer[] imgId) {
public CustomFound(Activity context, ArrayList<String> itemNames, ArrayList<String> desc, ArrayList<String> dates, ArrayList<String> uids) {
super(context, R.layout.listview_layout,itemNames);
this.context = context;
this. itemNames = new String[itemNames.size()];
for(int i = 0; i < itemNames.size(); i ++)
{
this.itemNames[i] = itemNames.get(i);
}
this.desc = new String[desc.size()];
for(int i = 0; i < desc.size(); i ++)
{
this.desc[i] = desc.get(i);
}
this. dates = new String[dates.size()];
for(int i = 0; i < dates.size(); i ++)
{
this.dates[i] = dates.get(i);
}
this. uids = new String[uids.size()];
for(int i = 0; i < uids.size(); i ++)
{
this.uids[i] = uids.get(i);
}
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
View r = convertView;
ViewHolder viewHolder = null;
if (r== null)
{
LayoutInflater layoutInflater = context.getLayoutInflater();
r = layoutInflater.inflate(R.layout.listview_layout, null, true);
viewHolder = new ViewHolder(r);
r.setTag(viewHolder);
}
else
{
viewHolder = (ViewHolder) r.getTag();
}
//viewHolder.iv.setImageResource(imgId[position]);
viewHolder.tv1.setText("Item name: " + itemNames[position]);
viewHolder.tv2.setText("Description: " + desc[position]);
viewHolder.tv3.setText("Date of upload: " + dates[position]);
viewHolder.tv4.setText("UID: " + uids[position]);
return r;
}
class ViewHolder {
TextView tv1;
TextView tv2;
TextView tv3;
TextView tv4;
ImageView iv;
ViewHolder(View v)
{
tv1 = v.findViewById(R.id.itemName);
tv2 = v.findViewById(R.id.description);
tv3 = v.findViewById(R.id.extra);
tv4 = v.findViewById(R.id.uid);
iv = v.findViewById(R.id.image);
}
}
}