scorpion01

Untitled

Sep 30th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1. package com.example.hapus;
  2.  
  3. import androidx.appcompat.app.AppCompatActivity;
  4. import androidx.recyclerview.widget.LinearLayoutManager;
  5. import androidx.recyclerview.widget.RecyclerView;
  6. import android.os.Bundle;
  7. import java.util.ArrayList;
  8.  
  9. public class MainActivity extends AppCompatActivity {
  10.     RecyclerView mRecyclerView;
  11.     MyAdapter myAdapter;
  12.  
  13.     @Override
  14.     protected void onCreate(Bundle savedInstanceState) {
  15.         super.onCreate(savedInstanceState);
  16.         setContentView(R.layout.activity_main);
  17.         mRecyclerView = findViewById(R.id.rec);
  18.         mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
  19.         myAdapter = new MyAdapter(this, getMyList());
  20.         mRecyclerView.setAdapter(myAdapter);
  21.     }
  22.  
  23.     private ArrayList<Model> getMyList() {
  24.         ArrayList<Model> models = new ArrayList<>();
  25.         Model m = new Model();
  26.         m.setTitle("News Feed");
  27.         m.setDescription("This is newsfeed for example recyclerview and textview for example");
  28.         m.setImg(R.drawable.newsfeed);
  29.         models.add(m);
  30.  
  31.         m = new Model();
  32.         m.setTitle("Business");
  33.         m.setDescription("This is Business");
  34.         m.setImg(R.drawable.business);
  35.         models.add(m);
  36.  
  37.         m = new Model();
  38.         m.setTitle("People");
  39.         m.setDescription("This is People");
  40.         m.setImg(R.drawable.people);
  41.         models.add(m);
  42.  
  43.         m = new Model();
  44.         m.setTitle("Notes");
  45.         m.setDescription("This is Notes");
  46.         m.setImg(R.drawable.notes);
  47.         models.add(m);
  48.  
  49.         m = new Model();
  50.         m.setTitle("Feedback");
  51.         m.setDescription("This is Feedback");
  52.         m.setImg(R.drawable.feedback);
  53.         models.add(m);
  54.  
  55.         return models;
  56.     }
  57. }
Add Comment
Please, Sign In to add comment