Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Make a Custom ArrayAdapter for ListView
    primarykey
    data
    text
    <p>I have to make a custom <code>ArrayAdapter</code> from the <code>JSON</code> response I'm getting. Here is my code from where I'm getting response and putting it in simple <code>ArrayAdapter</code> with <code>android.R.layout.simple_list_item_1</code></p> <pre><code>ListView lv = (ListView) findViewById(R.id.list); try { HttpClient hClient = new DefaultHttpClient(); HttpGet hGet = new HttpGet( "API HERE"); ResponseHandler&lt;String&gt; rHandler = new BasicResponseHandler(); data = hClient.execute(hGet, rHandler); JSONObject rootObj = new JSONObject(data); JSONObject searchObj = rootObj.getJSONObject("searchdata"); JSONArray titlesObj = searchObj.getJSONArray("titles"); JSONArray descsObj = searchObj.getJSONArray("desc"); JSONArray linksObj = searchObj.getJSONArray("links"); String[] a = new String[titlesObj.length()]; String[] b = new String[descsObj.length()]; String[] c = new String[linksObj.length()]; for (int i = 0; i &lt; titlesObj.length(); i++) { String title = titlesObj.getString(i); a[i] = title; } for (int i = 0; i &lt; descsObj.length(); i++) { String desc = descsObj.getString(i); b[i] = desc; } for (int i = 0; i &lt; linksObj.length(); i++) { String link = linksObj.getString(i); c[i] = link; } ArrayList&lt;String&gt; al = new ArrayList&lt;String&gt;(); for (int i = 0; i &lt; linksObj.length(); i++) { al.add(" " + a[i] + " " + b[i] + "" + c[i] + ""); } ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;( MainActivity.this, android.R.layout.simple_list_item_1, al); lv.setAdapter(adapter); } catch (Exception e) { } </code></pre> <p>Here, is the screenshot of my view:</p> <p><img src="https://i.stack.imgur.com/yJtoA.png" alt="OUTPUT of my CODE"></p> <p>I want to show the view which has three <code>TextView</code> one for the title, another one for URL and the last one for description.</p> <p>Any help will be appreciated.</p>
    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