title: I have got this error (Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference)
body: <blockquote>
  <blockquote>
  <p>I am trying to display the API data in the recyclerView but facing
  this error In the viewHolder.I'm trying to set the text of the textviews from the fetched data on my API, but when i try to do so, it
  throws the following error (Attempt to invoke virtual method 'void
  android.widget.TextView.setText(java.lang.CharSequence)' on a null
  object reference)</p>
  </blockquote>
  </blockquote>
  <p>package com.example.restfulapi;</p>
  <pre><code>import androidx.annotation.NonNull;
  import androidx.appcompat.app.AppCompatActivity;
  import androidx.recyclerview.widget.LinearLayoutManager;
  import androidx.recyclerview.widget.RecyclerView;
  
  import android.os.Bundle;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ImageView;
  import android.widget.LinearLayout;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.squareup.picasso.Picasso;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import retrofit2.Call;
  import retrofit2.Callback;
  import retrofit2.Response;
  
  public class DataViewActivity extends AppCompatActivity {
  RecyclerView recyclerView;
      private static final String TAG = &quot;DataViewActivity&quot;;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.data_view);
  
          recyclerView = findViewById(R.id.recycle);
          listingData();
          LinearLayoutManager llm =  new LinearLayoutManager(getApplicationContext(),LinearLayoutManager.VERTICAL, false );
          recyclerView.setLayoutManager(llm);
  
      }
  
      private void listingData() {
  
          Methods methods = RetrofitClient.getRetrofitInstance().create(Methods.class);
          Call&lt;Model&gt; listingData = methods.getAllData();
          listingData.enqueue(new Callback&lt;Model&gt;() {
  
              @Override
              public void onResponse(Call&lt;Model&gt; call, Response&lt;Model&gt; response) {
                  if (response.isSuccessful()) {
  
                      recycleAdapter adapter =new recycleAdapter(response.body().getData());
                      recyclerView.setAdapter(adapter);
  
                  }
              }
  
              @Override
              public void onFailure(Call&lt;Model&gt; call, Throwable t) {
  
                  Toast.makeText(DataViewActivity.this, &quot;Failure&quot;, Toast.LENGTH_SHORT).show();
  
              }
          });
      }
  
      class recycleAdapter extends RecyclerView.Adapter&lt;recycleAdapter.MyViewHolder&gt;
      {
          List&lt;Model.data&gt; list;
  
          public recycleAdapter(List&lt;Model.data&gt; list) {
              this.list = list;
          }
  
          @NonNull
          @Override
          public recycleAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
              View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.users,null);
              recycleAdapter.MyViewHolder viewHolder = new recycleAdapter.MyViewHolder(view);
              return viewHolder;
          }
  
          @Override
          public void onBindViewHolder(@NonNull recycleAdapter.MyViewHolder holder, int position) {
             holder.userEmail.setText(list.get(position).getEmail());
              holder.firstName.setText(list.get(position).getFirst_name());
              holder.lastName.setText(list.get(position).getLast_name());
              Picasso.with(getApplicationContext()).load(list.get(position).getAvatar())
                      .placeholder(R.drawable.ic_launcher_background).fit().into(holder.userImage);
  
          }
  
          @Override
          public int getItemCount() {
              return list.size();
          }
  
          class MyViewHolder extends RecyclerView.ViewHolder{
  
              TextView firstName,lastName,userEmail;
              ImageView userImage;
  </code></pre>
  <blockquote>
  <p>There is an error on this section below, I have mentioned the error
  above.Am I missing something or did I do something wrong in my code?</p>
  </blockquote>
  <pre><code>            public MyViewHolder(@NonNull View itemView) {
                  super(itemView);
                  firstName =(TextView)  findViewById(R.id.firstName);
                  lastName = (TextView) findViewById(R.id.lastName);
                  userEmail = (TextView) findViewById(R.id.userEmail);
                  userImage = (ImageView) findViewById(R.id.userImage);
  
              }
          }
      }
  }
  </code></pre>