-
Notifications
You must be signed in to change notification settings - Fork 1
/
MainActivity.java
65 lines (54 loc) · 1.99 KB
/
MainActivity.java
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
package com.cat.reloaded.marwatasks;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle;
import android.widget.Adapter;
import com.cat.reloaded.marwatasks.adapter.ItemAdapter;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setupRecyclerView();
}
private void setupRecyclerView(){
RecyclerView recyclerView = findViewById(R.id.rv);
// LinearLayoutManager mngr= new LinearLayoutManager(this);
// recyclerView.setLayoutManager(mngr);//listview
GridLayoutManager mngr = new GridLayoutManager(this,2);
recyclerView.setLayoutManager(mngr);
ItemAdapter adapter = new ItemAdapter(this);
recyclerView.setAdapter(adapter);
List<CustomClass> items = setupDataSource();
adapter.setDataSource(items);
}
private List<CustomClass> setupDataSource(){
List<CustomClass> items = new ArrayList<>();
int images[] = {
R.drawable.cook,
R.drawable.croom,
R.drawable.download,
R.drawable.images,
R.drawable.ppp,
R.drawable.screen15,
R.drawable.sky,
R.drawable.vignettes_265x300_330690,
R.drawable.will,};
String names [] ={"Cooking Diary",
"Disc Pool",
"Empires and Puzzles",
"The Alchemist code",
"Pubg",
"Tiles Hop",
"Rolling Sky",
"Hungry shark",
"Will Hero"};
for (int i = 0; i <names.length ; i++) {
items.add(new CustomClass(names[i],images[i]));
}
return items;
}
}