title: Android ArrayAdapter and JSONArray
body: <p>I am new to Android Development. </p>
  
  <p>I purely like to work with JSON Objects and Arrays for my simple application considering the lightness of the JSON Carrier compared to XMLs.</p>
  
  <p>I had challenges with ArrayAdapter to populate the ListView.</p>
  
  <p>This is how I overcome and need your suggestions on it.</p>
  
  <pre><code>Extend the Adaptor class.
  </code></pre>
  
  <p>Then pass the JSONArray to the constructor.<br>
  Here the constructor calls super with <i><b>dummy</b></i> String array setting the length of the JSONArray.<br>
  Store the constructor arguments in class for further use.</p>
  
  <pre><code>public myAdaptor(Context context, int resource, JSONArray array)
  {
      super(context, resource, new String[array.length()]);
      // Store in the local varialbles to the adapter class.
      this.context = context;
      this.resource = resource;
      this.profiles = objects;
  }
  </code></pre>
  
  <p>The <b>getView()</b> will do the job of <B>fetching</B> JSONObjects from JSONArray to build view.</p>
  
  <pre><code>public View getView(int position, View convertView, ViewGroup parent)
  {
      View view;
      if (convertView == null)
      {
          LayoutInflater inflater = (LayoutInflater) 
              context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          view = inflater.inflate(resource, parent, false);
      }
      else
      {
          view = convertView;
      }
  
      // Here 
      JSONObject item = (JSONObject) profiles.getJSONObject(position);
  
      // READY WITH JSONObject from the JSONArray
      // YOUR CODE TO BUILD VIEW OR ACCESS THE 
  }
  </code></pre>
  
  <p><b>Now Any improvements/suggestions/thoughful-question??</b></p>