Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.hapus;
- import androidx.appcompat.app.AppCompatActivity;
- import androidx.recyclerview.widget.LinearLayoutManager;
- import androidx.recyclerview.widget.RecyclerView;
- import android.os.Bundle;
- import java.util.ArrayList;
- public class MainActivity extends AppCompatActivity {
- RecyclerView mRecyclerView;
- MyAdapter myAdapter;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- mRecyclerView = findViewById(R.id.rec);
- mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
- myAdapter = new MyAdapter(this, getMyList());
- mRecyclerView.setAdapter(myAdapter);
- }
- private ArrayList<Model> getMyList() {
- ArrayList<Model> models = new ArrayList<>();
- Model m = new Model();
- m.setTitle("News Feed");
- m.setDescription("This is newsfeed for example recyclerview and textview for example");
- m.setImg(R.drawable.newsfeed);
- models.add(m);
- m = new Model();
- m.setTitle("Business");
- m.setDescription("This is Business");
- m.setImg(R.drawable.business);
- models.add(m);
- m = new Model();
- m.setTitle("People");
- m.setDescription("This is People");
- m.setImg(R.drawable.people);
- models.add(m);
- m = new Model();
- m.setTitle("Notes");
- m.setDescription("This is Notes");
- m.setImg(R.drawable.notes);
- models.add(m);
- m = new Model();
- m.setTitle("Feedback");
- m.setDescription("This is Feedback");
- m.setImg(R.drawable.feedback);
- models.add(m);
- return models;
- }
- }
Add Comment
Please, Sign In to add comment