title: How to set color code as per Json Object
body: <p>I have following Json Response,I am trying to set color as per DisplyText,but it only set last color code to whole String,</p>
  
  <p><a href="http://pastie.org/10850282" rel="nofollow">JSON Response</a></p>
  
  <p>JAVA Code</p>
  
  <pre><code> ch_list = new ArrayList&lt;String&gt;();
                          color_list=new ArrayList&lt;String&gt;();
  
                          try {
  
                              for (int i = 0; i &lt; response.length(); i++) {
  
                                  JSONObject person = (JSONObject) response
                                          .get(i);
  
                                  System.out.println("person"+person);
  
                                  String searchcode = person.getString("searchCode");
                                  System.out.println("searchcode"+searchcode);
  
  
  
  
  
                                  JSONArray ja = person.getJSONArray("itemList");
                                  for (int j = 0; j &lt; ja.length(); j++) {
  
                                       JSONObject jo = ja.getJSONObject(j);
  
                                      SearchResultModel ch = new SearchResultModel();
                                      ch.setSearch_Name(jo.getString("productName"));
                                      ch.setSearch_Img(jo.getString("productImage"));
                                      ch.setSearch_ImgLoc(jo.getString("productImageLoc"));
                                      ch.setSearch_Price(jo.getString("productSP"));
                                      ch.setSearch_RatingImg(jo.getString("pRatingImgName"));
                                      ch.setSearch_RatingImgPath(jo.getString("pRatingImgPath"));
  
                                      JSONArray txtdetail=jo.getJSONArray("productOfferText");
  
                                      System.out.println("txtdetailarray"+txtdetail);
  
                                      StringBuilder sb = new StringBuilder();
                                      for(int k=0;k&lt;txtdetail.length();k++)
                                      {
                                          JSONObject jdetail=txtdetail.getJSONObject(k);
  
  
  
                                          disptext=jdetail.getString("displayText");
                                          dispclr=jdetail.getString("displayColor");
                                          ch_list.add(disptext);
                                          color_list.add(dispclr);
                                          sb.append(disptext);
  
                                          System.out.println("clr" + color_list.get(k).toString());
                                          colors=color_list.get(k);
  
  
                                          String string = colors;
                                          String[] parts = string.split("\\*");
                                          int part1 = Integer.parseInt(parts[0]);
                                          int part2 = Integer.parseInt(parts[1]);
                                          int part3 = Integer.parseInt(parts[2]);
  
  
                                           hex = String.format("#%02X%02X%02X", part1, part2, part3);
                                          System.out.println("hexa"+hex);
  
                                         // System.out.println("textnames" + ch_list.get(k).toString());
  
  
                                      }
  
  
  
  
                                      detailtext=sb.toString().replaceAll("\\\\n", "\n");
  
                                    //  System.out.println("gh"+sb.toString()+detailtext);
                                      System.out.println("Output: " + sb.toString().replaceAll("\\\\n", "\n"));
  
                                      searchlist.add(ch);
  
                                  }
  
  
                              }
  </code></pre>
  
  <p>Adapter</p>
  
  <pre><code>public class CustomListAdapterCountry extends BaseAdapter {
          private  AQuery aQuery;
          private Activity activity;
          private LayoutInflater inflater;
          private List&lt;SearchResultModel&gt; movieItems;
          private List&lt;String&gt; DispItems;
  
          ImageLoader imageLoader = MyApplication.getInstance().getImageLoader();
  
  
          public CustomListAdapterCountry(Activity activity, List&lt;SearchResultModel&gt; movieItems,ArrayList&lt;String&gt; DispItems) {
              this.activity = activity;
              this.movieItems = movieItems;
              this.DispItems = DispItems;
              aQuery = new AQuery(this.activity);
          }
  
          @Override
          public int getCount() {
              return movieItems.size();
          }
  
          @Override
          public Object getItem(int location) {
              return movieItems.get(location);
          }
  
          @Override
          public long getItemId(int position) {
              return position;
          }
  
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
  
              if (inflater == null)
                  inflater = (LayoutInflater) activity
                          .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              if (convertView == null)
                  convertView = inflater.inflate(R.layout.list_item_searchresult, null);
  
              if (imageLoader == null)
                  imageLoader = MyApplication.getInstance().getImageLoader();
  
              NetworkImageView iv = (NetworkImageView) convertView
                      .findViewById(R.id.search_image);
  
             ImageView ratingiv = (ImageView) convertView
                      .findViewById(R.id.search_rating);
  
  
              TextView title = (TextView) convertView.findViewById(R.id.search_title);
              TextView price = (TextView) convertView.findViewById(R.id.search_price);
              TextView dettext = (TextView) convertView.findViewById(R.id.search_detailtext);
              // getting movie data for the row
              SearchResultModel m = movieItems.get(position);
  
  
  
  
              iv.setImageUrl(m.getSearch_ImgLoc() + m.getSearch_Img(), imageLoader);
  
              aQuery.id(ratingiv).image(m.getSearch_RatingImgPath() + m.getSearch_RatingImg(), true, true, 0, R.mipmap.ic_launcher);
  
  
              //Log.d("searchimgs", joined);
  
              // title
              title.setText(m.getSearch_Name());
              price.setText("$"+m.getSearch_Price());
              dettext.setText(detailtext);
  
  
  
              dettext.setTextColor(Color.parseColor(hex));
  
              return convertView;
          }
  
      }
  </code></pre>