title: Attempt to read from field 'android.view.View androidx.recyclerview.widget.RecyclerView$ViewHolder.itemView' on a null object reference
body: <p>I am making an app that gets data from sql and puts it in a recycle view i first tried it in a list view but i found it easier in a recycle view it is basically like a chat system app anyways,when i add my data into the recycle view it gives me this error in the logcat.</p>
  
  <pre><code> java.lang.NullPointerException: Attempt to read from field
         'android.view.View
         androidx.recyclerview.widget.RecyclerView$ViewHolder.itemView' on a
         null object reference
                 at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:7079)
                 at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6235)
                 at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118)
                 at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114)
                 at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2303)
                 at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1627)
                 at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1587)
                 at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:665)
                 at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4134)
                 at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3851)
                 at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4404)
                 at android.view.View.layout(View.java:18010)
                 at android.view.ViewGroup.layout(ViewGroup.java:5817)
                 at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1080)
                 at android.view.View.layout(View.java:18010)
                 at android.view.ViewGroup.layout(ViewGroup.java:5817)
                 at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
                 at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
                 at android.view.View.layout(View.java:18010)
                 at android.view.ViewGroup.layout(ViewGroup.java:5817)
                 at androidx.appcompat.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:444)
                 at android.view.View.layout(View.java:18010)
                 at android.view.ViewGroup.layout(ViewGroup.java:5817)
                 at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
                 at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
                 at android.view.View.layout(View.java:18010)
                 at android.view.ViewGroup.layout(ViewGroup.java:5817)
                 at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
                 at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
                 at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
  </code></pre>
  
  <p>Please help because it doesn't give me any clue on where is the error coming from or stuff like that.</p>
  
  <p>here is my adapter class:</p>
  
  <pre><code>public class MyAppAdapter extends 
  
  RecyclerView.Adapter&lt;MyAppAdapter.ViewHolder&gt;//has a class viewholder which holds
          {
              private ArrayList&lt;ClassListChat&gt; mOriginalValues; // Original Values
              private ArrayList&lt;ClassListChat&gt; mDisplayedValues;
  
              public class ViewHolder extends RecyclerView.ViewHolder {
  
                  TextView messageText;
                  TextView messageUser;
                  TextView messageTime;
  
                  public ViewHolder(@NonNull View itemView) {
                      super(itemView);
                  }
              }
  
              public List &lt;ClassListChat&gt; parkingList;
  
              public Context context;
              ArrayList&lt;ClassListChat&gt; arraylist;
  
  
              private MyAppAdapter(List&lt;ClassListChat&gt; apps, Context context) {
                  this.parkingList = apps;
                  this.context = context;
                  arraylist = new ArrayList&lt;ClassListChat&gt;();
                  arraylist.addAll(parkingList);
              }
  
  
  
              @Override
              public MyAppAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,int viewType) {
                  View rowView = LayoutInflater.from(parent.getContext()).inflate(R.layout.listcontentstorechat,parent,false);
                  ViewHolder viewHolder = new ViewHolder(rowView);
                  if (rowView == null) {
                      LayoutInflater inflater = getLayoutInflater();
                      rowView = inflater.inflate(R.layout.listcontentstorechat, parent, false);
                      viewHolder.messageText = (BubbleTextView) rowView.findViewById(R.id.message_text);
                      viewHolder.messageUser = (TextView) rowView.findViewById(R.id.message_user);
                      viewHolder.messageTime = (TextView) rowView.findViewById(R.id.message_time);
                      rowView.setTag(viewHolder);
                  } else {
                      viewHolder = (ViewHolder) rowView.getTag();
                  }
                  // here setting up names and images
  
  
  
  
                  return viewHolder;
              }
  
              @Override
              public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
                  holder.messageText.setText(parkingList.get(position).getMessageText());
                  holder.messageUser.setText(parkingList.get(position).getMessageUser());
                  holder.messageTime.setText(DateFormat.format("dd-MM-yyyy (HH:mm:ss)", parkingList.get(position).getMessageTime()));
              }
  
              @Override
              public int getItemCount() {
                  return itemArrayList.size();
              }
          }
  
  
  I would really appreciate your hard work in helping me!!
  </code></pre>
  
  <p><strong>EDIT:</strong> now it just gives me a blank bubbleTextView(which i implemented into my app)but it doesn't show the text,nor the time,nor the user any ideas?</p>
  
  <p>Here is my listcontentstorechat.xml:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;TextView
          android:layout_alignParentTop="true"
          android:layout_alignParentStart="true"
          android:layout_alignParentLeft="true"
          android:id="@+id/message_user"
          android:textStyle="normal|bold"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
      &lt;TextView
          android:layout_alignParentBottom="@+id/message_user"
          android:layout_alignParentEnd="true"
          android:layout_alignParentRight="true"
          android:id="@+id/message_time"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
      &lt;com.github.library.bubbleview.BubbleTextView
          android:layout_alignParentStart="true"
          android:layout_alignParentLeft="true"
          android:layout_marginTop="5dp"
          android:layout_below="@id/message_user"
          android:textAppearance="@style/TextAppearance.AppCompat.Body1"
          android:textColor="#FFF"
          android:textSize="18sp"
  
          android:id="@+id/message_text"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:padding="10dp"
          app:arrowWidth="8dp"
          app:angle="8dp"
          app:arrowHeight="10dp"
          app:arrowPosition="14dp"
          app:arrowLocation="left"
          app:bubbleColor="#333639"
          app:arrowCenter="true"
          /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>And here is my ClassListChat.java</p>
  
  <pre><code>public class ClassListChat {
      public String messageText;
      public String messageUser;
      public long messageTime;
  
  
      public ClassListChat(String messageText, String messageUser) {
          this.messageText = messageText;
          this.messageUser = messageUser;
          messageTime = new Date().getTime();
      }
  
      public ClassListChat() {
      }
  
      public String getMessageText() {
          return messageText;
      }
  
      public void setMessageText(String messageText) {
          this.messageText = messageText;
      }
  
      public String getMessageUser() {
          return messageUser;
      }
  
      public void setMessageUser(String messageUser) {
          this.messageUser = messageUser;
      }
  
      public long getMessageTime() {
          return messageTime;
      }
  
      public void setMessageTime(long messageTime) {
          this.messageTime = messageTime;
      }
  </code></pre>
  
  <p><strong>EDIT2:</strong> After some improvements it now returns an error in the logcat saying:</p>
  
  <pre><code> java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
          at com.example.medicnes.ChatActivity$MyAppAdapter.onBindViewHolder(ChatActivity.java:275)
          at com.example.medicnes.ChatActivity$MyAppAdapter.onBindViewHolder(ChatActivity.java:225)
          at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7065)
          at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7107)
          at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6012)
          at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6279)
          at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118)
          at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114)
  </code></pre>