title: arrayAdapter = infinite loop? (cf: code)
body: <p>So i have 2 questions about this ArrayAdapter :<br>
  1. the third parameter <code>List&lt;RSSItem&gt; list</code> in the constructor is automatically analysed in <code>getView</code>, and <code>position</code> will iterate through each item in this <code>list</code> ? (so the only important thing to do is call <code>super</code> to pass this list as a parameter?)</p>
  
  <p>2.at the end of the code, we have <code>new MyCustomAdapter(this, R.layout.row, myRssFeed.getList());</code> how this can work, and not create an infite loop in the code? because at the end of the arrayAdapter, the class calls itself to restart the adapter... how does the adapter end?</p>
  
  <p>here's the code (source: <a href="http://android-er.blogspot.com/2010/07/simple-rss-reader-with-options-menu-to.html" rel="nofollow">http://android-er.blogspot.com/2010/07/simple-rss-reader-with-options-menu-to.html</a> ) :</p>
  
  <pre><code>public class AndroidRssReader extends ListActivity {
  
  private RSSFeed myRssFeed = null;
  
  TextView feedTitle;
  TextView feedDescribtion;
  TextView feedPubdate;
  TextView feedLink;
  
  public class MyCustomAdapter extends ArrayAdapter&lt;RSSItem&gt; {
  
   public MyCustomAdapter(Context context, int textViewResourceId,
     List&lt;RSSItem&gt; list) {
    super(context, textViewResourceId, list);
   }
  
   @Override
   public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    //return super.getView(position, convertView, parent);
  
    View row = convertView;
  
    if(row==null){
     LayoutInflater inflater=getLayoutInflater();
     row=inflater.inflate(R.layout.row, parent, false);
    }
  
    TextView listTitle=(TextView)row.findViewById(R.id.listtitle);
    listTitle.setText(myRssFeed.getList().get(position).getTitle());
    TextView listPubdate=(TextView)row.findViewById(R.id.listpubdate);
    listPubdate.setText(myRssFeed.getList().get(position).getPubdate());
  
    if (position%2 == 0){
     listTitle.setBackgroundColor(0xff101010);
     listPubdate.setBackgroundColor(0xff101010);
    }
    else{
     listTitle.setBackgroundColor(0xff080808);
     listPubdate.setBackgroundColor(0xff080808);
    }
  
    return row;
   }
  }
  
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
  
   feedTitle = (TextView)findViewById(R.id.feedtitle);
   feedDescribtion = (TextView)findViewById(R.id.feeddescribtion);
   feedPubdate = (TextView)findViewById(R.id.feedpubdate);
   feedLink = (TextView)findViewById(R.id.feedlink);
  
        readRss();
    }
  
    private void readRss(){
  
   feedTitle.setText("--- wait ---");
   feedDescribtion.setText("");
   feedPubdate.setText("");
   feedLink.setText("");
   setListAdapter(null);
  
   Toast.makeText(this, "Reading RSS, Please wait.", Toast.LENGTH_LONG).show();
  
        try {
    URL rssUrl = new URL("http://www.gov.hk/en/about/rss/govhkrss.data.xml");
    SAXParserFactory mySAXParserFactory = SAXParserFactory.newInstance();
    SAXParser mySAXParser = mySAXParserFactory.newSAXParser();
    XMLReader myXMLReader = mySAXParser.getXMLReader();
    RSSHandler myRSSHandler = new RSSHandler();
    myXMLReader.setContentHandler(myRSSHandler);
    InputSource myInputSource = new InputSource(rssUrl.openStream());
    myXMLReader.parse(myInputSource);
  
    myRssFeed = myRSSHandler.getFeed();
  
   } catch (MalformedURLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   } catch (ParserConfigurationException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   } catch (SAXException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
  
   if (myRssFeed!=null)
   {
    Calendar c = Calendar.getInstance();
       String strCurrentTiime =  "\n(Time of Reading - "
             + c.get(Calendar.HOUR_OF_DAY)
             + " : "
             + c.get(Calendar.MINUTE) + ")\n";
  
    feedTitle.setText(myRssFeed.getTitle() + strCurrentTiime);
    feedDescribtion.setText(myRssFeed.getDescription());
    feedPubdate.setText(myRssFeed.getPubdate());
    feedLink.setText(myRssFeed.getLink());
  
    MyCustomAdapter adapter =
     new MyCustomAdapter(this, R.layout.row, myRssFeed.getList());
    setListAdapter(adapter);
  
   }
    }
  </code></pre>
  
  <p>EDIT :
  in this example, how "view" can be null?</p>
  
  <pre><code>private class MyAdapter extends ArrayAdapter&lt;String&gt; {
  
      public MyAdapter(Context context, List&lt;String&gt; objects) {
          super(context, R.layout.list_item, R.id.text, objects);
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          View view = convertView;
          Wrapper wrapper;
  
          if (view == null) {
              view = mInflater.inflate(R.layout.list_item, null);
              wrapper = new Wrapper(view);
              view.setTag(wrapper);
          } else {
              wrapper = (Wrapper) view.getTag();
          }
  </code></pre>
  
  <p>Thanks</p>