title: How to set data in RecyclerView on Android
body: <p>I want get some data from server and show it into <code>Recyclerview</code>. I can show this data, but some time not show this data and just show progressBar.<br>
  I show this data in <code>Log.e</code> and show <strong>fastly</strong>, but not show this data in <code>RecyclerView</code> and just show Progress.<br>
  <strong>Please see below picture to know my mean :</strong> <br>
  <a href="https://s8.postimg.org/i58gcazg5/image.jpg" rel="nofollow noreferrer">Click too see</a></p>
  
  <p><strong>My Response codes:</strong></p>
  
  <pre><code>InterfaceApi api = ApiClient.getClient().create(InterfaceApi.class);
  Call&lt;CountryResponse&gt; call = api.getCountryList();
  
  call.enqueue(new Callback&lt;CountryResponse&gt;() {
      @Override
      public void onResponse(Call&lt;CountryResponse&gt; call, Response&lt;CountryResponse&gt; response) {
          try {
              if (response.body() != null) {
                  models.clear();
                  models.addAll(response.body().getData());
                  for (int i = 0; i &lt;= models.size(); i++) {
                      Log.e("CountryInfoTAG", response.body().getData().get(i).getId() + " : " +
                              response.body().getData().get(i).getName());
                  }
  
                  countryProgress.setVisibility(View.GONE);
                  countryRecycler.setAdapter(mAdapter);
              }
          } catch (Exception e) {
          }
      }
  
      @Override
      public void onFailure(Call&lt;CountryResponse&gt; call, Throwable t) {
          Toasty.error(context, context.getResources().getString(R.string.failRequest),
                  Toast.LENGTH_LONG, true).show();
      }
  });
  </code></pre>
  
  <p><strong>Adapter codes:</strong></p>
  
  <pre><code>public class CountryAdapter extends RecyclerView.Adapter {
  
      private List&lt;CountryDatum&gt; mData;
      private Context context;
      private sendDataListener listner;
  
      public CountryAdapter(List&lt;CountryDatum&gt; mData, Context context, sendDataListener listner) {
          this.mData = mData;
          this.context = context;
          this.listner = listner;
  
      }
  
      @Override
      public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          RecyclerView.ViewHolder vh;
          View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_country, parent, false);
          vh = new DataViewHolder(v);
  
          return vh;
      }
  
      @Override
      public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
          if (holder instanceof DataViewHolder) {
              ((DataViewHolder) holder).countryListTxt.setText(mData.get(position).getName() + "");
              ((DataViewHolder) holder).countryListTxt.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                      listner.onSendIdName(mData.get(position).getId(), mData.get(position).getName());
  
                      if (context instanceof RegisterActivity) {
                          ((RegisterActivity) context).dismissCountryDialog();
                      }
                  }
              });
          }
      }
  
      @Override
      public int getItemCount() {
          return mData.size();
      }
  
      public void add(List&lt;CountryDatum&gt; models) {
          mData.addAll(models);
          notifyDataSetChanged();
      }
  
      public void clear() {
          mData.clear();
          notifyDataSetChanged();
      }
  
      public class DataViewHolder extends RecyclerView.ViewHolder {
          private TextView countryListTxt;
  
          public DataViewHolder(View itemView) {
              super(itemView);
  
              countryListTxt = (TextView) itemView.findViewById(R.id.countryNameTxt);
          }
      }
  }
  </code></pre>
  
  <p>How can I fix? please help me. 
  How can I fix? please help me</p>