Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7030685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:42:15+00:00 2026-05-28T00:42:15+00:00

So i have 2 questions about this ArrayAdapter : 1. the third parameter List<RSSItem>

  • 0

So i have 2 questions about this ArrayAdapter :
1. the third parameter List<RSSItem> list in the constructor is automatically analysed in getView, and position will iterate through each item in this list ? (so the only important thing to do is call super to pass this list as a parameter?)

2.at the end of the code, we have new MyCustomAdapter(this, R.layout.row, myRssFeed.getList()); 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?

here’s the code (source: http://android-er.blogspot.com/2010/07/simple-rss-reader-with-options-menu-to.html ) :

public class AndroidRssReader extends ListActivity {

private RSSFeed myRssFeed = null;

TextView feedTitle;
TextView feedDescribtion;
TextView feedPubdate;
TextView feedLink;

public class MyCustomAdapter extends ArrayAdapter<RSSItem> {

 public MyCustomAdapter(Context context, int textViewResourceId,
   List<RSSItem> 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);

 }
  }

EDIT :
in this example, how “view” can be null?

private class MyAdapter extends ArrayAdapter<String> {

    public MyAdapter(Context context, List<String> 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();
        }

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:42:16+00:00Added an answer on May 28, 2026 at 12:42 am
    1. Yea! there is a method getItem(int position) that will return the item at that specific position from your provide List. and another method int getCount() will tell the adapter about how many items are their.

    2. their is no infinite loop. the ArrayAdaptersimply calls super to avail the inherited properties and both methods getItem() and getCount()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two questions about the following code. 1. How to constructor the third
I have a few questions about this after reading the iPhone documentation on it:
I have couple of questions about AS3 variables handling by AVM/compiler/scope .1. This code
I have some questions about this window: What type this window is (I've found
I'm using NSURLConnection as listed below. I have three questions about this class. When
I have two questions about this: I am trying to assign an image to
I have few questions about this code: <?php $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); $iv =
I have found serval questions about this but no one helps for me, I
I have read questions and answers about this topic but I still have some
I have seen some other questions about this, but none of the answers really

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.