stack overflow recyclerview

Solutions on MaxInterview for stack overflow recyclerview by the best coders in the world

showing results for - "stack overflow recyclerview"
Tam
26 Jun 2016
1DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
2    layoutManager.getOrientation());
3recyclerView.addItemDecoration(dividerItemDecoration);
Fynn
05 Nov 2020
1public class MainActivity extends AppCompatActivity implements MyRecyclerViewAdapter.ItemClickListener {
2
3    MyRecyclerViewAdapter adapter;
4
5    @Override
6    protected void onCreate(Bundle savedInstanceState) {
7        super.onCreate(savedInstanceState);
8        setContentView(R.layout.activity_main);
9
10        // data to populate the RecyclerView with
11        ArrayList<String> animalNames = new ArrayList<>();
12        animalNames.add("Horse");
13        animalNames.add("Cow");
14        animalNames.add("Camel");
15        animalNames.add("Sheep");
16        animalNames.add("Goat");
17
18        // set up the RecyclerView
19        RecyclerView recyclerView = findViewById(R.id.rvAnimals);
20        recyclerView.setLayoutManager(new LinearLayoutManager(this));
21        adapter = new MyRecyclerViewAdapter(this, animalNames);
22        adapter.setClickListener(this);
23        recyclerView.setAdapter(adapter);
24    }
25
26    @Override
27    public void onItemClick(View view, int position) {
28        Toast.makeText(this, "You clicked " + adapter.getItem(position) + " on row number " + position, Toast.LENGTH_SHORT).show();
29    }
30}
Michele
16 Oct 2016
1<?xml version="1.0" encoding="utf-8"?>
2<RelativeLayout
3    xmlns:android="http://schemas.android.com/apk/res/android"
4    android:layout_width="match_parent"
5    android:layout_height="match_parent">
6
7    <android.support.v7.widget.RecyclerView
8        android:id="@+id/rvAnimals"
9        android:layout_width="match_parent"
10        android:layout_height="match_parent"/>
11
12</RelativeLayout>
Jessica
31 Nov 2018
1<?xml version="1.0" encoding="utf-8"?>
2<LinearLayout
3    xmlns:android="http://schemas.android.com/apk/res/android"
4    android:layout_width="match_parent"
5    android:layout_height="wrap_content"
6    android:orientation="horizontal"
7    android:padding="10dp">
8
9    <TextView
10        android:id="@+id/tvAnimalName"
11        android:layout_width="wrap_content"
12        android:layout_height="wrap_content"
13        android:textSize="20sp"/>
14
15</LinearLayout>
Veronica
23 Jul 2016
1implementation 'com.android.support:appcompat-v7:28.0.0'
2implementation 'com.android.support:recyclerview-v7:28.0.0'