title: Android Displaying data from json to cardview in RecyclerView
body: <p>I want to display data from webservice to cardview in recycleviewer. It had already success to display data. But it only display one data, although it has a lot of data to display.
  Can you help me to solve this problem? Thank you</p>
  
  <p><strong>Seller.java</strong></p>
  
  <pre><code>public class Seller {
      String penjual,image,alamat,telp;
  
      public String getPenjual() {
          return penjual;
      }
  
      public void setPenjual(String penjual) {
          this.penjual = penjual;
      }
  
      public String getImage() {
          return image;
      }
  
      public void setImage(String image) {
          this.image = image;
      }
  
      public String getAlamat() {
          return alamat;
      }
  
      public void setAlamat(String alamat) {
          this.alamat = alamat;
      }
  
      public String getTelp() {
          return telp;
      }
  
      public void setTelp(String telp) {
          this.telp = telp;
      }
  }
  </code></pre>
  
  <p><strong>SellerAdapter.Java</strong></p>
  
  <pre><code>import android.content.Context;
  import android.support.v7.widget.CardView;
  import android.support.v7.widget.RecyclerView;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  import com.amobi.lomapodfix.R;
  import com.amobi.lomapodfix.model.Seller;
  import com.squareup.picasso.Picasso;
  
  import java.util.ArrayList;
  import java.util.List;
  
  /**
   * Created by Nicky-PC on 5/4/2016.
   */
  public class SellerAdapter extends RecyclerView.Adapter&lt;SellerAdapter.PersonViewHolder&gt; {
  
      List&lt;Seller&gt; sellers;
      Context context;
      public SellerAdapter(Context context,List&lt;Seller&gt; sellers)
      {
          this.sellers=sellers;
          this.context=context;
      }
  
      public void setGridData(List&lt;Seller&gt; mGridData)
      {
          this.sellers=mGridData;
          notifyDataSetChanged();
      }
      @Override
      public PersonViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_toko, parent, false);
          PersonViewHolder pvh = new PersonViewHolder(v);
          return pvh;
      }
  
      @Override
      public void onBindViewHolder(PersonViewHolder holder, int i) {
          holder.Seller.setText(sellers.get(i).getPenjual());
          holder.Address.setText(sellers.get(i).getAlamat());
          holder.Telp.setText(sellers.get(i).getTelp());
          Picasso.with(context).load(sellers.get(i).getImage()).fit().into(holder.image);
      }
  
      @Override
      public int getItemCount() {
          return sellers.size();
      }
  
      public static class PersonViewHolder extends RecyclerView.ViewHolder {
          CardView cv;
          TextView Seller;
          TextView Address;
          TextView Telp;
          ImageView image;
  
          PersonViewHolder(View itemView) {
              super(itemView);
              cv = (CardView)itemView.findViewById(R.id.cv);
              Seller = (TextView)itemView.findViewById(R.id.lvSeller);
              Address = (TextView)itemView.findViewById(R.id.lvAlamat);
              Telp = (TextView)itemView.findViewById(R.id.lvAlamat);
              image= (ImageView)itemView.findViewById(R.id.person_photo);
          }
      }
      @Override
      public void onAttachedToRecyclerView(RecyclerView recyclerView) {
          super.onAttachedToRecyclerView(recyclerView);
      }
  }
  </code></pre>
  
  <p>DogFragment.java</p>
  
  <pre><code>import android.app.ProgressDialog;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.RecyclerView;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  import android.widget.SimpleAdapter;
  import android.widget.Toast;
  
  import com.amobi.lomapodfix.JSONParser;
  import com.amobi.lomapodfix.MainActivity;
  import com.amobi.lomapodfix.R;
  import com.amobi.lomapodfix.adapter.SellerAdapter;
  import com.amobi.lomapodfix.model.Seller;
  
  import org.apache.http.NameValuePair;
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  
  /**
   * A simple {@link Fragment} subclass.
   */
  public class DogFragment extends Fragment {
  
      SellerAdapter mGridadapter;
      JSONParser jParser= new JSONParser();
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; nameList;
      JSONArray names=null;
      RecyclerView data;
      List&lt;Seller&gt; mgridData;
      ProgressDialog pDialog;
      private static final String URL_TEST_ANJING = "http://lomapod.azurewebsites.net/readSellerAnjing.php";
      private static final String TAG_PESAN = "message";
      private static final String TAG_HASIL = "result";
      private static final String TAG_ID = "id_penjual";
      private static final String TAG_SELLER= "nama_toko";
      private static final String TAG_ALAMAT= "alamat_toko";
      private static final String TAG_TELP= "no_telp";
      private static final String TAG_IMAGE= "image_name";
      private RecyclerView.LayoutManager layoutManager;
  
  
      public DogFragment() {
          // Required empty public constructor
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          // Inflate the layout for this fragment
          View rootView=inflater.inflate(R.layout.fragment_dog, container, false);
          data=(RecyclerView) rootView.findViewById(R.id.rv);
          layoutManager = new LinearLayoutManager(getActivity());
          data.setLayoutManager(layoutManager);
          mgridData=new ArrayList&lt;&gt;();
          mGridadapter=new SellerAdapter(getActivity(),mgridData);
  
          new AmbilDataJsonAnjing().execute();
          return rootView;
      }
  
      public class AmbilDataJsonAnjing extends AsyncTask&lt;String,String,String&gt; {
  
          int sukses=0;
  
          public AmbilDataJsonAnjing() {
              pDialog = new ProgressDialog(getActivity());
          }
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              pDialog.setMessage("Mengambil Data. Silahkan Tunggu...");
              pDialog.setIndeterminate(false);
              pDialog.setCancelable(false);
              pDialog.show();
          }
  
          @Override
          protected String doInBackground(String... args) {
  
              List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
  
              try
              {
                  JSONObject json = jParser.makeHttpRequest(URL_TEST_ANJING, "GET", params);
                  Seller sellers=null;
                  if(json != null)
                  {
                      sukses = json.getInt(TAG_PESAN);
                      if(sukses == 1)
                      {
                          nameList = new ArrayList&lt;HashMap&lt;String,String&gt;&gt;();
                          Log.d("Semua Nama: ", json.toString());
                          names = json.getJSONArray(TAG_HASIL);
  
                          for(int i = 0; i &lt; names.length();i++)
                          {
                              JSONObject c = names.getJSONObject(i);
                              String id = c.getString(TAG_ID);
                              String seller = c.getString(TAG_SELLER);
                              String alamat=c.getString(TAG_ALAMAT);
                              String telp=c.getString(TAG_TELP);
                              String image=c.getString(TAG_IMAGE);
  
                              HashMap&lt;String,String&gt; map = new HashMap&lt;String,String&gt;();
  
                              sellers=new Seller();
                              sellers.setPenjual(seller);
                              sellers.setAlamat(alamat);
                              sellers.setTelp(telp);
                              sellers.setImage(image);
  
                              map.put(TAG_ID, id);
                              map.put(TAG_SELLER,seller);
                              map.put(TAG_ALAMAT,alamat);
                              map.put(TAG_TELP,telp);
                              nameList.add(map);
                              mgridData.add(sellers);
                          }
                      }
                  }
              }catch(JSONException e)
              {
                  e.printStackTrace();
              }
  
              return null;
          }
  
          @Override
          protected void onPostExecute(String s) {
              pDialog.dismiss();
              RecyclerView.Adapter adapter=new SellerAdapter(getActivity(),mgridData);
              if(sukses == 1 )
              {
                  mGridadapter.setGridData(mgridData);
                  data.setAdapter(adapter);
              }
              else
              {
                  Toast.makeText(getActivity(), "Error - No Data Available", Toast.LENGTH_SHORT).show();
              }
          }
      }
  
  }
  </code></pre>
  
  <p>And I get this in android monitor</p>
  
  <pre><code>05-04 23:35:55.874 5605-5668/com.amobi.lomapodfix D/url: http://lomapod.azurewebsites.net/readSellerAnjing.php?
  05-04 23:35:55.878 5605-5605/com.amobi.lomapodfix W/FragmentManager: moveToState: Fragment state for CatFragment{a9c44708 #1 id=0x7f0d007e android:switcher:2131558526:1} not updated inline; expected state 3 found 2
  05-04 23:35:55.938 5605-5605/com.amobi.lomapodfix W/EGL_emulation: eglSurfaceAttrib not implemented
  05-04 23:35:55.938 5605-5605/com.amobi.lomapodfix E/RecyclerView: No adapter attached; skipping layout
  05-04 23:35:55.946 5605-5605/com.amobi.lomapodfix I/dalvikvm: Could not find method android.support.v7.widget.LinearLayoutCompat.drawableHotspotChanged, referenced from method android.support.design.internal.ForegroundLinearLayout.drawableHotspotChanged
  05-04 23:35:55.946 5605-5605/com.amobi.lomapodfix W/dalvikvm: VFY: unable to resolve virtual method 15705: Landroid/support/v7/widget/LinearLayoutCompat;.drawableHotspotChanged (FF)V
  05-04 23:35:55.946 5605-5605/com.amobi.lomapodfix D/dalvikvm: VFY: replacing opcode 0x6f at 0x0000
  05-04 23:35:55.958 5605-5608/com.amobi.lomapodfix D/dalvikvm: GC_CONCURRENT freed 374K, 8% free 55730K/60500K, paused 2ms+1ms, total 9ms
  05-04 23:35:56.098 5605-5668/com.amobi.lomapodfix I/info: org.apache.http.client.methods.HttpGet@a9c7a668
  05-04 23:35:56.098 5605-5668/com.amobi.lomapodfix D/Semua Nama:: {"message":1,"result":[{"no_telp":"08345678","nama_toko":"lomapod","image_name":null,"id_image":"1","no_rek":"12345","email":"sekar@gmail.com","id_penjual":"1","alamat_toko":"jl.bbbbb","kota":"Yogyakarta","nama_bank":"BBB"},{"no_telp":"0829417","nama_toko":"meow","image_name":null,"id_image":"1","no_rek":"12345","email":"nicky@gmail.com","id_penjual":"2","alamat_toko":"jl.ccccc","kota":"Yogyakarta","nama_bank":"BNI"}]}
  05-04 23:35:56.682 5605-5605/com.amobi.lomapodfix W/EGL_emulation: eglSurfaceAttrib not implemented
  05-04 23:35:56.702 5605-5605/com.amobi.lomapodfix I/Choreographer: Skipped 42 frames!  The application may be doing too much work on its main thread.
  05-04 23:35:56.706 5605-5605/com.amobi.lomapodfix E/RecyclerView: No adapter attached; skipping layout
  05-04 23:35:56.918 5605-5605/com.amobi.lomapodfix W/Settings: Setting airplane_mode_on has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value.
  </code></pre>