I know this question has been asked so many times, but none of the solutions answered there seems to solve my problem.

Most of the solutions suggested attaching an adapter (`setadapter()`) and I have done that. But the problem still seems to persist.

I also checked if my `listitems` are **empty** and it isn't.

I have attached the adapter in a function **`loadUserAccounts()`**.

```
 protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_accounts);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        // Swipe to refresh
        swipeRefresh = (SwipeRefreshLayout) findViewById(R.id.userSwipeRefresh);

        //Recycler View
        recyclerView = (RecyclerView) findViewById(R.id.userRecyclerView);
        recyclerView.setHasFixedSize(true);
        recyclerView.setLayoutManager(new LinearLayoutManager(userAccountsActivity.this));
        listItems = new ArrayList<>();
        recyclerViewUserAdapter = new RecyclerViewUserAdapter(listItems, userAccountsActivity.this);
        recyclerView.setAdapter(recyclerViewUserAdapter);

        //Function to load the users to the recycler view
        loadUserAccounts();

        /*
        * Sets up a SwipeRefreshLayout.OnRefreshListener that is invoked when the user
        * performs a swipe-to-refresh gesture.
        */
        swipeRefresh.setOnRefreshListener(
                new SwipeRefreshLayout.OnRefreshListener() {
                    @Override
                    public void onRefresh() {
                        Log.i("Swipe_log: ", "onRefresh called from SwipeRefreshLayout");

                        // This method performs the actual data-refresh operation.
                        // The method calls setRefreshing(false) when it's finished.
                        loadUserAccounts();
                    }
                }
        );
    }

```

and this is my **`loadUserAccounts()`** function:

```
   /**
     * Function to load the user account
     * into the recycler view from the log database
     */
   public void loadUserAccounts(){

        String tag_string_req = "req_user_acc";
        clear();

        StringRequest stringRequest = new StringRequest(Request.Method.GET, URL_USER_ACCOUNTS, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {

                    JSONArray jArray = new JSONArray(response);

                    for(int i = jArray.length()-1; i>=0; i--){
                        JSONObject log = jArray.getJSONObject(i);

                        String name = log.getString("name");
                        String cpfNumber = log.getString("cpfNumber");
                        String type = log.getString("type");
                        String created_at = log.getString("created_at");

                        Log.d("Adapter: ", name + cpfNumber + type + created_at);
                        ListItem_RecyclerView_User item = new ListItem_RecyclerView_User (name, cpfNumber, type, created_at);
                        listItems.add(item);
                    }
                    recyclerViewUserAdapter.updateDataList(responseList);

                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                if(error!=null && error.getMessage() !=null){
                    Log.e(TAG,"User Accounts Error: " + error.getMessage());
                    Toast.makeText(getApplicationContext(),error.getMessage(), Toast.LENGTH_LONG).show();
                }
                else{
                    Toast.makeText(getApplicationContext(),"Something went wrong",Toast.LENGTH_LONG).show();
                }
            }
        });

        //Adding request to request queue
        AppController.getInstance().addToRequestQueue(stringRequest, tag_string_req);
       if (swipeRefresh == null)
           return;
       else {
           if (swipeRefresh.isRefreshing()) {
               swipeRefresh.setRefreshing(false);
           }
       }
    }

```

My adapter class `RecyclerViewUserAdapter`

```
public class RecyclerViewUserAdapter extends RecyclerView.Adapter<RecyclerViewUserAdapter.ViewHolder> {

    private List<ListItem_RecyclerView_User> listItems;
    private Context context;

    public RecyclerViewUserAdapter(List<ListItem_RecyclerView_User> listItems, Context context) {
        this.listItems = listItems;
        this.context = context;
    }

    public void updateDataList(List<ListItem_RecyclerView_User> newDatas) {
        listItems.clear();
        listItems.addAll(newDatas);
        notifyDataSetChanged();
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.users_recycler_item, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerViewUserAdapter.ViewHolder holder, int position) {
        ListItem_RecyclerView_User listItem = listItems.get(position);

        holder.txtUserName.setText(listItem.getTxtUserName());
        holder.txtUserCpf.setText(listItem.getTxtUserCpf());
        holder.txtAccountType.setText(listItem.getTxtAccountType());

        try {
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = null;
            date = df.parse(listItem.getTxtCreatedDate());
            SimpleDateFormat sdf = new SimpleDateFormat("h:mm a");
            String loginTime = sdf.format(date);

            holder.txtCreatedDate.setText(loginTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }

    @Override
    public int getItemCount() {
        return 0;
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        private TextView txtUserName;
        private TextView txtUserCpf;
        private TextView txtAccountType;
        private TextView txtCreatedDate;

        public ViewHolder(View itemView) {
            super(itemView);
            txtUserName = (TextView) itemView.findViewById(R.id.txtUserName);
            txtUserCpf = (TextView) itemView.findViewById(R.id.txtUserCpf);
            txtAccountType = (TextView) itemView.findViewById(R.id.txtAccountType);
            txtCreatedDate = (TextView) itemView.findViewById(R.id.txtCreatedDate);
        }
    }
}

```