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

  • Home
  • SEARCH
  • 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 9204741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:46:53+00:00 2026-06-17T23:46:53+00:00

In one of my android activity, I’ve a ListView lvFeedsList . Each row element

  • 0

In one of my android activity, I’ve a ListView lvFeedsList.
Each row element in the listView will contain 3 textViews – RSSFeedName, publishDate & feedLength

The contents of the feeds is retrived from a HTTPRsponse.
I’m fetching this response in an AsyncTask.

So, in the doInBackground(), I’ve send the HTTPRequest & received & parsed the response & prepared the ArrayList containing 3 above mentioned information.

Then inside the doInBackground() only, I’m creating the customized ArrayAdapter for forming the 3 TextViews in row element.
My intetions are to set this adapter on ListView in onPostExecute().

But, when I run the application, the ListView does not display anything.

I tried to debug & it seems like getView() in the ArrayAdapter class is not getting called. (But I’m not sure if this is the reason).

Here is the code, sorry for the length…it seemed necessary.

Activity Code:

public class GenericFeedsActivity extends Activity{

    private ListView lvFeedsList;
    private ArrayList<FeedsClass> feedList;

    protected void onCreate(Bundle savedInstanceState) {
        ...
        lvFeedsList = (ListView) findViewById(R.id.lvFeedsList);
        lvFeedsList.setOnItemClickListener(this);
        lvFeedsList.setEnabled(false);
        ...
        new AsyncResponseHandler(this).execute();
    }

    class AsyncResponseHandler extends AsyncTask {
        Context context;
        FeedListAdapter adapter;

        public AsyncResponseHandler(Context c) {
            this.context = c;
        }

        @Override
        protected Object doInBackground(Object... params) {
            ...
            /* 
             *  Sending HTTPRequest to a URL & getting list of feeds
             *  Saving this list of feeds in a ArrayList -feedList, containing elements of type FeedsClass (declared above)
             *  Below line parses the HTTPResponse XML & stores various information in feedList.
             */
            feedList = utils.parseRssResponseXML(in);   // Working fine, geeting elements
            adapter = new FeedListAdapter(
                GenericFeedsActivity.this, feedList);
            in.close();
            return null;
        }

        protected void onPostExecute(Object e) {
            // Setting Arrayadapter
            lvFeedsList.setAdapter(adapter);
            lvFeedsList.setEnabled(true);
        }
    }
}

Adapter Code:

public class FeedListAdapter extends ArrayAdapter {

    private Context context;
    private ArrayList<FeedsClass> feedList;

    public FeedListAdapter(Context c, ArrayList<FeedsClass> data) {
        super(c, R.layout.rowlayout);
        this.context = c;
        this.feedList = data;
    }

    class ViewHolder {
        TextView tvFeedName;
        TextView tvFeedPubDate;
        TextView tvFeedLength;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View row = convertView;
        ViewHolder holder = null;
            if (row == null) {

                LayoutInflater inflator = (LayoutInflater) context
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                row = inflator.inflate(R.layout.rowlayout, null);
                holder = new ViewHolder();

                holder.tvFeedName = (TextView) row.findViewById(R.id.tvFeedName);
                holder.tvFeedPubDate = (TextView) row.findViewById(R.id.tvFeedPubDate);
                holder.tvFeedLength = (TextView) row.findViewById(R.id.tvFeedLength);

                row.setTag(holder);
            } else {
                holder = (ViewHolder) row.getTag();
            }
            // Getting values of feedName, publishDate & feedLength
            String feedName = feedList.get(position).getTitle();
            String feedDate = feedList.get(position).getPublishDate();
            String feedLength = feedList.get(position).getStreamLength();

            holder.tvFeedName.setText(feedName);
            holder.tvFeedPubDate.setText(feedDate);
            holder.tvFeedLength.setText(feedLength);
        }
        return row;
    }
}
  • 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-06-17T23:46:54+00:00Added an answer on June 17, 2026 at 11:46 pm

    The issue is that you are subclassing ArrayAdapter. This doesn’t work because ArrayAdapter internally thinks you do not have any elements in your data; it doesn’t just magically know to look in the lvFeedsList variable because the data set it uses is internal.

    Instead, in your constructor make sure to call this constructor instead:

    Adapter code:

    public FeedListAdapter(Context c, ArrayList<FeedsClass> data) {
        super(c, R.layout.rowlayout, data); // add 'data'
        this.context = c;
        this.feedList = data;
    }
    

    Which will make everything work correctly.

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

Sidebar

Related Questions

I am developing one android application, having the listview activity. I displayed the activity.
Can any one please help me how to go to another activity in android
My Android Application has only one activity called MainActivity . When I press the
Possible Duplicate: How to pass object from one activity to another in Android I
I have implemented onRetainNonConfigurationInstance() on one of my Activity to handle android screen orientation.
I'm developing an Android application. On one activity I have a List with list
I've already written some small Android Applications, most of them in one Activity and
I'm using Intents, to pass an array from one Activity to another in Android.
Mac OSX 10.6.4 Nexus One Android 2.2 The command adb devices will list my
i am developing one android application,there i need to change layout of activity at

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.