Home Ask Login Register

Developers Planet

Your answer is one click away!

Prasang February 2016

Android Recyclerview not showing any data

I took this tutorial as reference. Despite of checking everything, no data is appearing on screen ie. main_activity. I've already referred to other pages on stackoverflow regarding this issue. Can't find a viable solution.

NOTE: There is no warning or error while I deploy app on the device.

This is the source code.


public class MainActivity extends Activity
private RecyclerView mRecyclerView;
private RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;

protected void onCreate(Bundle savedInstanceState)

    mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);
    mLayoutManager = new LinearLayoutManager(this);
    mAdapter = new MyRecyclerViewAdapter(getDataSet());
    RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(this, LinearLayoutManager.VERTICAL);

    // Code to Add an item with default animation
    DataObject obj = new DataObject("red", "foo");
    ((MyRecyclerViewAdapter) mAdapter).addItem(obj, 0);

    // Code to remove an item with default animation
    //((MyRecyclerViewAdapter) mAdapter).deleteItem(index);

protected void onResume() {
    ((MyRecyclerViewAdapter) mAdapter).setOnItemClickListener(new MyRecyclerViewAdapter.MyClickListener()
        public void onItemClick(int position, View v) {
            Toast.makeText(MainActivity.this, "Clicked item: " + position, Toast.LENGTH_SHORT).show();

private ArrayList<DataObject> getDataSet() {
    ArrayList results = new Array        


Dalma Racz February 2016

The problem is in activity_main.xml. You should remove ScrollView and it will work (There's no reason to have one since the recyclerview has an implicit one). There is no scrollview in the tutorial either: check activity_recycler_view.xml.

Post Status

Asked in February 2016
Viewed 2,408 times
Voted 6
Answered 1 times


Leave an answer

Quote of the day: live life