title: How to retrieve data from json array and display in textview?
body: <p>I've been using the coding from an example from <a href="http://fahmirahman.wordpress.com/2011/04/21/connection-between-php-server-and-android-client-using-http-and-json/" rel="nofollow noreferrer">this link</a>:  The code is as shown below:</p>
  
  <pre><code>public class food extends ListActivity {
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          String result = null;
          InputStream is = null;
          StringBuilder sb=null;
          String result=null;
              TextView fdi = (TextView)findViewById(R.id.textView1);
              TextView fdn = (TextView)findViewById(R.id.textView2);
  
          //http post
          try{
              HttpClient httpclient = new DefaultHttpClient();
              HttpPost httppost = new HttpPost("http://127.0.0.1/food.php");
              httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
              HttpResponse response = httpclient.execute(httppost);
              HttpEntity entity = response.getEntity();
              is = entity.getContent();
          }catch(Exception e){
              Log.e("log_tag", "Error in http connection"+e.toString());
          }
  
          //convert response to string
          try{
              BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
              sb = new StringBuilder();
              sb.append(reader.readLine() + "\n");
              String line="0";
  
              while ((line = reader.readLine()) != null) {
                  sb.append(line + "\n");
              }
  
              is.close();
              result=sb.toString();
  
          }catch(Exception e){
              Log.e("log_tag", "Error converting result "+e.toString());
          }
  
          //paring data
          int fd_id;
          String fd_name;
          try{
          jArray = new JSONArray(result);
          JSONObject json_data=null;
  
          for(int i=0;i&lt;jArray.length();i++){
                  json_data = jArray.getJSONObject(i);
                  fd_id=json_data.getInt("FOOD_ID");
                  fd_name=json_data.getString("FOOD_NAME");
          }
  
          }catch(JSONException e1){
              Toast.makeText(getBaseContext(), "No Food Found", Toast.LENGTH_LONG).show();
          }catch (ParseException e1){
              e1.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>Now my question is how to pass this data to a list view, like for each iteration a list item must be added with the retrieved data.</p>
  
  <p>Please help me</p>
  
  <p>Thanks in advance</p>