title: How to Display data from JSON using of Gson
body: <p>i have URL Link of json data &amp; I displayed data like Color Name ,Color Code in RecyclerView in my app Except Shape data.
  how to display Shape Data also???
  this is my Json Url Link : <a href="https://raw.githubusercontent.com/ianbar20/JSON-Volley-Tutorial/master/Example-JSON-Files/Example-Array.JSON" rel="nofollow noreferrer">https://raw.githubusercontent.com/ianbar20/JSON-Volley-Tutorial/master/Example-JSON-Files/Example-Array.JSON</a></p>
  
  <p><a href="https://i.stack.imgur.com/R33KJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R33KJ.png" alt="enter image description here"></a></p>
  
  <p>this is my AboutTask class</p>
  
  <pre><code>public class AboutTask extends AsyncTask&lt;JSONObject, String, AboutResponse&gt; {
  
  OkHttpClient okHttpClient = new OkHttpClient();
  Gson gson = new Gson();
  
  @Override
  protected AboutResponse doInBackground(JSONObject... params) {
      try {
  
          JSONObject jsonObject = params[0];
  
          //String url = "http://bitstobyte.in/api/about";
          String url = "https://raw.githubusercontent.com/ianbar20/JSON-Volley-Tutorial/master/Example-JSON-Files/Example-Array.JSON";
  
          Request request = new Request.Builder().url(url).build();
  
          Response response = okHttpClient.newCall(request).execute();
  
          if (!response.isSuccessful()) {
              Log.v("About_Answer", "About_Failed");
              throw new IOException("about_UnExpected Code" + response);
          }
  
          String strResponse = response.body().string();
  
          Log.e("about_strResponse", strResponse);
  
          AboutMainResponse[] aboutMainResponse = gson.fromJson(strResponse, AboutMainResponse[].class);
  
          //System.out.println(Arrays.toString(aboutMainResponse));
  
          System.out.println(aboutMainResponse);
  
          Log.e("aboutResp", "AboutResponse" + aboutMainResponse);
          return aboutMainResponse[0];
  
      } catch (NullPointerException e) {
          e.printStackTrace();
      } catch (IOException e) {
          Log.e("About_searchTask", e.toString());
      } catch (Exception e) {
          e.printStackTrace();
      }
      return null;
  }
  
  }
  </code></pre>
  
  <p>this is About_Fragment </p>
  
  <pre><code>public class About_Fragment extends android.support.v4.app.Fragment {
  JSONObject jsonObject;
  
  private List&lt;AboutData&gt; aboutDataList = new ArrayList&lt;&gt;();
  private RecyclerView recyclerView;
  private AboutAdapter aboutAdapter;
  public About_Fragment() {
      // Required empty public constructor
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      // Inflate the layout for this fragment
  
      View rootView = inflater.inflate(R.layout.fragment_about_,container,false);
  
      recyclerView = (RecyclerView)rootView.findViewById(R.id.recyclerView);
  
      //recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
  
      recyclerView.setHasFixedSize(true);
  
      RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
      recyclerView.setLayoutManager(mLayoutManager);
      //recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
      recyclerView.setItemAnimator(new DefaultItemAnimator());
  
      recyclerView.setAdapter(aboutAdapter);
      aboutAdapter = new AboutAdapter(aboutDataList,getContext());
  
      new AboutTask(){
          @Override
          protected void onPostExecute(AboutResponse aboutResponse) {
              if (aboutResponse != null &amp;&amp; aboutResponse.colorArray != null &amp;&amp; aboutResponse.colorArray.size() &gt; 0) {
                  //if (aboutResponse != null &amp;&amp; aboutResponse.shapeArray != null &amp; aboutResponse.shapeArray.size() &gt; 0)
  
                      aboutDataList = aboutResponse.colorArray;
  
                      //aboutDataList = aboutResponse.shapeArray;
  
                      aboutAdapter = new AboutAdapter(aboutDataList, getContext());
  
                      recyclerView.setAdapter(aboutAdapter);
                  }
                  Log.i("resp", "onPostExecute");
              }
      }.execute(jsonObject);
      return rootView;
  }
  }
  </code></pre>
  
  <p>This is my AboutResponse code:</p>
  
  <pre><code>public class AboutResponse {
  
  public List&lt;AboutData&gt; shapeArray;
  public List&lt;AboutData&gt; colorArray;
  }
  </code></pre>
  
  <p>This is AboutMainResponse:</p>
  
  <pre><code>public class AboutMainResponse extends AboutResponse {
  
  // public AboutResponse aboutResponse;
  
  }
  </code></pre>
  
  <p>This is My AboutAdapter code :</p>
  
  <pre><code>public class AboutAdapter extends    RecyclerView.Adapter&lt;AboutAdapter.MyViewHolder&gt; {
  
  private List&lt;AboutData&gt; aboutDataList;
  private Context context;
  
  public class MyViewHolder extends RecyclerView.ViewHolder {
      public TextView colorName;
      public ImageView nextArrowimage;
      public TextView hexaValue,title_three;
      private AboutData aboutData=null;
  
      public MyViewHolder(View view) {
          super(view);
          colorName = (TextView) view.findViewById(R.id.title_one);
          nextArrowimage = (ImageView)view.findViewById(R.id.about_NextArrow);
          hexaValue = (TextView) view.findViewById(R.id.title_two);
          title_three = (TextView)view.findViewById(R.id.title_three);
          view.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
              }
          });
      }
  }
  
  
  public AboutAdapter(List&lt;AboutData&gt; aboutDataList,Context context) {
      this.aboutDataList = aboutDataList;
      this.context = context;
  }
  
  @Override
  public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_items, parent, false);
      MyViewHolder holder = new MyViewHolder(itemView);
      return new MyViewHolder(itemView);
  }
  
  @Override
  public void onBindViewHolder(final MyViewHolder holder, final int position) {
      final AboutData aboutData = aboutDataList.get(position);
      holder.hexaValue.setText(aboutData.getHexValue());
      holder.colorName.setText(aboutData.getColorName());
      holder.title_three.setText(aboutData.getShapeArray());
  
      holder.nextArrowimage.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
  
              String colorName = aboutData.getColorName();
              String hexaValue = aboutData.getHexValue();
              Intent intent = new Intent(context,Display_Activity.class);
              intent.putExtra("colorName",colorName);
              intent.putExtra("hexaValue",hexaValue);
              context.startActivity(intent);
  
          }
      });
  }
  @Override
  public int getItemCount() {
      return aboutDataList.size();
  }
  
  }
  </code></pre>