-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCategoryAdapter_k.java
More file actions
56 lines (44 loc) · 1.35 KB
/
CategoryAdapter_k.java
File metadata and controls
56 lines (44 loc) · 1.35 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
package com.example.quizapp;
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.List;
import java.util.Random;
public class CategoryAdapter_k extends BaseAdapter {
private List <String> catList;
public CategoryAdapter_k(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.cat_item_layout_k, 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;
}
}