Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.mylist;
- import android.os.Bundle;
- import android.widget.Button;
- import androidx.appcompat.app.AppCompatActivity;
- import androidx.recyclerview.widget.LinearLayoutManager;
- import androidx.recyclerview.widget.RecyclerView;
- import java.util.ArrayList;
- public class MainActivity extends AppCompatActivity {
- private RecyclerView rcvItems;
- private Button btnOK;
- private ArrayList<Item> data;
- private MyAdapter adapter;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- rcvItems = findViewById(R.id.rcvItems);
- btnOK = findViewById(R.id.btnOK);
- data = new ArrayList<>();
- data.add(new Item("Saleh", 10));
- data.add(new Item("Ali", 15));
- data.add(new Item("Amneh", 20));
- data.add(new Item("Saleh", 10));
- data.add(new Item("Ali", 15));
- data.add(new Item("Amneh", 20));
- data.add(new Item("Saleh", 10));
- data.add(new Item("Ali", 15));
- data.add(new Item("Amneh", 20));
- data.add(new Item("Saleh", 10));
- data.add(new Item("Ali", 15));
- data.add(new Item("Amneh", 20));
- data.add(new Item("Saleh", 10));
- data.add(new Item("Ali", 15));
- data.add(new Item("Amneh", 20));
- data.add(new Item("Saleh", 10));
- data.add(new Item("Ali", 15));
- data.add(new Item("Amneh", 20));
- data.add(new Item("Saleh", 10));
- data.add(new Item("Ali", 15));
- data.add(new Item("Amneh", 20));
- data.add(new Item("Saleh", 10));
- data.add(new Item("Ali", 15));
- data.add(new Item("Amneh", 20));
- adapter = new MyAdapter(data);
- RecyclerView.LayoutManager manager = new LinearLayoutManager(this);
- rcvItems.setLayoutManager(manager);
- rcvItems.setAdapter(adapter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement