Maruf_Hasan

MainFunction

Apr 4th, 2021
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. package com.example.recyclerview;
  2.  
  3. import androidx.appcompat.app.AppCompatActivity;
  4. import androidx.recyclerview.widget.LinearLayoutManager;
  5. import androidx.recyclerview.widget.RecyclerView;
  6.  
  7. import android.os.Bundle;
  8.  
  9. public class MainActivity extends AppCompatActivity {
  10. RecyclerView r1;
  11. String s1[],s2[];
  12. int image_Resource[]={R.drawable.cat,R.drawable.dog,R.drawable.cat,R.drawable.dog,R.drawable.cat,R.drawable.dog,R.drawable.cat,R.drawable.dog};
  13. MyAdapter MAdptr;
  14. @Override
  15. protected void onCreate(Bundle savedInstanceState) {
  16. super.onCreate(savedInstanceState);
  17. setContentView(R.layout.activity_main);
  18. r1=(RecyclerView)findViewById(R.id.recycler_view);
  19. s1=getResources().getStringArray(R.array.petname);
  20. s2=getResources().getStringArray(R.array.Petdescription);
  21. MAdptr=new MyAdapter(this,s1,s2,image_Resource);
  22. r1.setAdapter(MAdptr);
  23. r1.setLayoutManager(new LinearLayoutManager(this));
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment