Home » Android » Getting Android RecyclerView to update view inside React Native component

Getting Android RecyclerView to update view inside React Native component

Posted by: admin May 14, 2020 Leave a comment


I am making a mobile application using React Native and included list components didn’t have high enough performance for it so I started using Android’s RecyclerView as the list component. There is a problem though with it. The RecyclerView doesn’t update its contents views until I scroll or change RecyclerView’s size. What could cause this problem and how I can fix it? I have tried notifyDatasetChanged, notifyItemChanged, forceLayout, invalidate, postInvalidate and many different variations with each.

How to&Answers:

enter image description hereTry this one this.setIsRecyclable(true);

It will referesh your views

public class MainActivity extends AppCompatActivity {

    private RecyclerView mRecyclerView;
    private ArrayList<String> mSingleItemLists = new ArrayList<>();
    private SingleListItemAdapter mSingleListItemAdapter;

    protected void onCreate(Bundle savedInstanceState) {
        mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_single_item);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);

    private void setDummyData() {
        for (int i = 0; i <= 30; i++)
            mSingleItemLists.add("item" + i);

    protected void onResume() {
        mSingleListItemAdapter = new SingleListItemAdapter(mSingleItemLists);

    class SingleListItemAdapter extends RecyclerView.Adapter<SingleListItemAdapter.SingleListItemHolder> {
        private ArrayList<String> mSingleItemLists;

        private SingleListItemAdapter(ArrayList<String> singleItemLists) {
            mSingleItemLists = singleItemLists;
            //You can do notifydatasetchange if u r having any saved value 

        public SingleListItemAdapter.SingleListItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View inflatedView = LayoutInflater.from(parent.getContext())
                    .inflate(R.layout.row_recyclerview, parent, false);
            return new SingleListItemHolder(inflatedView);

        public void onBindViewHolder(SingleListItemAdapter.SingleListItemHolder holder, int position) {

        public int getItemCount() {
            return mSingleItemLists.size();

        class SingleListItemHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
            private TextView mItemDate;

            SingleListItemHolder(View v) {
                mItemDate = (TextView) v.findViewById(R.id.textview_recycler_list_item);
                this.setIsRecyclable(true); // This will help u 

            public void onClick(View v) {
                //do your stuff