-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathactivity_CatAdapter_t.java
More file actions
57 lines (44 loc) · 1.37 KB
/
activity_CatAdapter_t.java
File metadata and controls
57 lines (44 loc) · 1.37 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
package com.example.quiz_app;
import java.util.List;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.Random;
public class activity_CatAdapter_t extends BaseAdapter{
private List<String> catList = null;
public activity_CatAdapter_t(List<String> catList) {
this.catList = catList;
}
@Override
public int getCount() {
return catList.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view;
if(convertView == null)
{
view= LayoutInflater.from(parent.getContext()).inflate(R.layout.set_item_layout_t, parent, false);
}
else
{
view = convertView;
}
((TextView) view.findViewById(R.id.catName)).setText(catList.get(position));
Random random = new Random();
int color = Color.argb(255, random.nextInt(255),random.nextInt(255), random.nextInt(255));
view.setBackgroundColor(color);
return view;
}
}