-1

enter image description here

I want to show image listing like below image using gridlayoutmanager span.

Gundu Bandgar
  • 2,593
  • 1
  • 17
  • 21

3 Answers3

0

You can use

(*) You can use the GridLayoutManager only if the items can be draw as a grid. In this case you can use the method setSpanSizeLookup(SpanSizeLookup) to change the default span (=1).

Something like:

layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                return // your implementation ...... ;
            }
        });
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
0

You can use GridLayoutManager with default span count as 1 and can set the width at the run time inside the adapter class in setItemViewType() Method.

Kuldeep Rathee
  • 282
  • 2
  • 7
0
private void parseJsons()
{
    try {
        JSONObject object=new JSONObject(json);

// JSONObject object=jsonObject.getJSONObject("Meta Data");

        Iterator<String> it = object.keys();
        while (it.hasNext()) {
            String key = it.next();
            try {
                 if (object.get(key) instanceof JSONObject) {
                     Log.e("Main OBJ",key);
                     JSONObject object2=object.getJSONObject(key);
                     Iterator<String> it2 = object2.keys();
                     while (it2.hasNext()) {
                         String key2 = it2.next();
                             if (object2.get(key2) instanceof JSONObject) {
                                 Log.e("Sub OBJ",key2);
                                 JSONObject object3=object2.getJSONObject(key2);
                                 Iterator<String> it3 = object3.keys();
                                 while (it3.hasNext()) {
                                     String key4 = it3.next();
                                     Log.e("Values",key4);
                                 }
                             } else {
                                 System.out.println(key + ":" + object.getString(key));
                             }
                     }
                 } else {
                    System.out.println(key + ":" + object.getString(key));
                }
            } catch (Throwable e) {
                try {
                    System.out.println(key + ":" + object.getString(key));
                } catch (Exception ee) {
                }
                e.printStackTrace();

            }
        }


    } catch (JSONException e) {
        e.printStackTrace();
    }
}


String json="{\n" +
        "    \"Meta Data\": {\n" +
        "        \"1. Information\": \"Intraday (15min) open, high, low, close prices and volume\",\n" +
        "        \"2. Symbol\": \"AAME\",\n" +
        "        \"3. Last Refreshed\": \"2019-11-18 16:00:00\",\n" +
        "        \"4. Interval\": \"15min\",\n" +
        "        \"5. Output Size\": \"Compact\",\n" +
        "        \"6. Time Zone\": \"US/Eastern\"\n" +
        "     },\n" +
        "    \"Time Series (15min)\": {\n" +
        "        \"2019-11-18 16:00:00\": {\n" +
        "            \"1. open\": \"1.6700\",\n" +
        "            \"2. high\": \"1.6700\",\n" +
        "            \"3. low\": \"1.5700\",\n" +
        "            \"4. close\": \"1.5700\",\n" +
        "            \"5. volume\": \"1521\"\n" +
        "        },\n" +
        "        \"2019-11-18 15:45:00\": {\n" +
        "            \"1. open\": \"1.6600\",\n" +
        "            \"2. high\": \"1.7400\",\n" +
        "            \"3. low\": \"1.6600\",\n" +
        "            \"4. close\": \"1.7400\",\n" +
        "            \"5. volume\": \"355\"\n" +
        "        }\n" +
        "    }\n" +
        "}";
Gundu Bandgar
  • 2,593
  • 1
  • 17
  • 21