title: JSONArray in a ListView with Android
body: <p>urlHi i've this code that works receiving data from a php page and i want to put that data in a listview. I receive that data and i've seen that with a system.out.println but i have white rows in the listview. Code:</p>
  <pre><code>public class Utenti extends ListActivity {
  
  
  ListView lv;
      
  ListView listView;
  
  static String temp;
      //ListAdapter adapter;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      
  
      
             
          
            
      StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
      
        StrictMode.setThreadPolicy(policy);
        
      
  
  
  lv = getListView();
  lv.setTextFilterEnabled(true);
  lv.setOnItemClickListener(new OnItemClickListener() {
      public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
          
  
          }
      });
  
       
        
  
        
        Thread t = new Thread(new Runnable (){
  
            public void run() {
                //Looper.prepare();
                JSONObject json =conn(&quot;ketut.php&quot;);
  
                try {
                    //Get the element that holds the earthquakes ( JSONArray )
                    JSONArray  ute = json.getJSONArray(&quot;success&quot;);
                    final List&lt;HashMap&lt;String, String&gt;&gt; mylist = 
                            new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
                    HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
                       for(int i=0;i &lt; ute.length();i++){
  
                        JSONObject e = ute.getJSONObject(i);
                         System.out.println(e.getString(&quot;user&quot;));
  
                        
                        
                         map.put(&quot;name&quot;,  e.getString(&quot;user&quot;));
                         
                        
                       
                         mylist.add(map);
                    }
  
                       runOnUiThread(new Runnable() {
  
  
                           public void run() {
  
                            ListAdapter adapter = new SimpleAdapter(Utenti.this, mylist , R.layout.utentii,new String[] { &quot;name&quot; },new int[] { 1});
                            Utenti.this.setListAdapter(adapter);
                            }
  
                        });
  
                } catch (JSONException e) {
                    System.out.println(&quot;4&quot;);
                    e.printStackTrace();
                }
  
            }
        });
                t.start();
          //  t.start();  
        
  
       
  
  
          
  
  }
  
  
  public  static JSONObject conn(String pagina){
      HttpURLConnection connection;
      OutputStreamWriter request = null;
      URL url = null;
      String response = null;
      JSONObject jArray = null;
      
  
      try
          {
              url = new URL(&quot;url&quot;+pagina);
              connection = (HttpURLConnection) url.openConnection();
              connection.setDoOutput(true);
              connection.setRequestProperty(&quot;Content-Type&quot;, &quot;application/x-www-form-urlencoded&quot;);
              connection.setRequestMethod(&quot;POST&quot;);
  
              
              String line = &quot;&quot;;
  
              InputStreamReader isr = new InputStreamReader(connection.getInputStream());
              BufferedReader reader = new BufferedReader(isr);
              StringBuilder sb = new StringBuilder();
              while ((line = reader.readLine()) != null)
              {
                  sb.append(line + &quot;\n&quot;);
              }
              response = sb.toString();
              System.out.println(response);
              try{jArray=new JSONObject (response);}
              catch(JSONException e){}
              
              isr.close();
              reader.close(); 
          }
          catch(IOException e)
          {
              Log.i(&quot;NetworkTest&quot;,&quot;Network Error: &quot; + e);
          }
      return jArray;
  }}
  </code></pre>
  <p>utentii.xml</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;TextView xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  android:layout_width=&quot;fill_parent&quot;
  android:layout_height=&quot;fill_parent&quot;
  android:padding=&quot;10dp&quot;
  android:textSize=&quot;20sp&quot; &gt;
  </code></pre>
  
  <p><a href="http://img854.imageshack.us/img854/6540/rowsa.jpg" rel="nofollow noreferrer">Image of the problem</a></p>