Note that there are some explanatory texts on larger screens.

plurals
  1. POPlace an Image (loaded from URL) and Edit text box in Grid view in Android
    primarykey
    data
    text
    <p>Some one please help me to place an Image ( display image in the grid view from URL) and Edittextbox in Android Grid View</p> <p>This is my grid view xml lay out:</p> <pre><code> &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" /&gt; &lt;GridView android:id="@+id/order_details_grid" android:layout_width="fill_parent" android:layout_height="fill_parent" android:numColumns="4" android:columnWidth="100px" android:stretchMode="columnWidth" android:gravity="center"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>below is the code which i use to populate the grid and it is working fine , i need to place the image coming from the url and and edittextbox:</p> <pre><code> super.onCreate(savedInstanceState); setContentView(R.layout.order_details); File yourFile = new File("/sdcard/json/orderdetails.txt"); FileInputStream stream = null; try { stream = new FileInputStream(yourFile); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } String jString = ""; try { FileChannel fc = stream.getChannel(); MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()); /* Instead of using default, pass in a decoder.*/ jString = Charset.defaultCharset().decode(bb).toString(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { stream.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } String fileContent=jString; JSONObject jobj = null; JSONObject jobj1 = null; try { jobj = new JSONObject(fileContent); } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { JSONArray ja = jobj.getJSONArray("ORDERDETAILS"); listContent.add("ITEM NAME"); listContent.add("ORDER QUANTITY"); listContent.add("PRICE"); listContent.add("PREFERED SHOP"); for(int i=0; i&lt;ja.length(); i++){ String ORDERDETAILS = ja.getString(i); System.out.println(ORDERDETAILS); jobj1 = new JSONObject(ORDERDETAILS); String ITEMNAME = jobj1.getString("ITEMNAME"); listContent.add(ITEMNAME); System.out.println(ITEMNAME); String ORDERQUANTITY = jobj1.getString("ORDERQUANTITY"); listContent.add(ORDERQUANTITY); System.out.println(ORDERQUANTITY); String PRICE = jobj1.getString("PRICE"); listContent.add(PRICE); System.out.println(PRICE); String SHOPNAME = jobj1.getString("SHOPNAME"); System.out.println(SHOPNAME); listContent.add(SHOPNAME); } } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } gridView = (GridView)findViewById(R.id.order_details_grid); ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt; (this,android.R.layout.simple_list_item_1,listContent); gridView.setAdapter(adapter); // gridView.setAdapter(new ImageAdapter(this)); </code></pre> <p>}</p> <p>This is my json file from which i fetched the json data:</p> <pre><code> { "ORDERDETAILS": [ { "ITEMNAME": "APPLE-LAPTOP", "ORDERQUANTITY": "35", "PRICE": "4500 DHMS", "SHOPNAME": "Indico Icon Kits 403", "SHOPIMAGEURL": "http://s0.geograph.org.uk/photos/43/03/430378_cc40fae8.jpg" }, { "ITEMNAME": "ASUS-NOTEBOOK", "ORDERQUANTITY": "35", "PRICE": "3500 DHMS", "SHOPNAME": "Indico Icon Kits 403", "SHOPIMAGEURL": "" }, { "ITEMNAME": "DELL-LAPTOP", "ORDERQUANTITY": "35", "PRICE": "9500 DHMS", "SHOPNAME": "Indico Icon Kits 403", "SHOPIMAGEURL": "" } ] } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload