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 898143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:59:47+00:00 2026-05-15T14:59:47+00:00

I am trying to add ListView items one by one. So if I have

  • 0

I am trying to add ListView items one by one. So if I have say — 60 items — the application would add the views to the list view one at a time — thus showing the user that the application is loading more things.

This is my code:

try {
        JSONArray j = getTaggsJSON();
        Log.v(TAG, String.valueOf(j.length()));
        a = new createSpecialAdapter(this, R.layout.individual_tagg_view,
                R.layout.list_item, view, j);
        ListView v = this.getListView();
        v.setStackFromBottom(true);
        setListAdapter(a);
        new addViewsToList().execute(j);

    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (ServiceException e) {
        e.printStackTrace();
    }

}

private class addViewsToList extends AsyncTask<JSONArray, View, List<View>> {

    protected List<View> doInBackground(JSONArray... jsonArrays) {
        List<View> v = new ArrayList<View>();
        Log.v(TAG, String.valueOf(jsonArrays[0].length()));
        for (int x = 0; x < jsonArrays[0].length(); x++) {
            try {
                Log.v(TAG, jsonArrays[0].getJSONObject(x).toString());
                v.add(ViewAdapter.createTaggView(jsonArrays[0]
                        .getJSONObject(x), c));
            } catch (JSONException e) {
                e.printStackTrace();
            }
            publishProgress(v.get(x));
        }
        return v;
    }

    protected void onProgressUpdate(View... v) {
        Log.v(TAG, "I'm updating my progress!");
        a.notifyDataSetChanged();
    }

    protected void onPostExecute(List<View> views) {
        Log.v(TAG, "i'm done!");
        Log.v(TAG, String.valueOf(views.size()));
    }
}

So, it looks like my code is printing out the views correctly, and putting them in the list correctly, however my activity displays nothing. What am I doing wrong? I thought setting the adapter before — when there are no views in the list — and then updating the adapter that the list was changed was the right way to go…. Obviously not.. Can anyone help me?

If you need clarification on my questions please let me know.

EDIT: Here is the adapter code to supplement my question.

private class SpecialAdapter extends ArrayAdapter<JSONArray> {

    JSONArray json;

    public SpecialAdapter(Context context, int textViewResourceId,
            int listItem, JSONArray j) {
        super(context, textViewResourceId);
        this.json = j;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        Log.v(TAG,"I'm inside the getView method.");
        try {
            JSONObject info = json.getJSONObject(position);
            Log.v(TAG,info.toString());



        if (convertView == null) {
            LayoutInflater i = (LayoutInflater) RecentTaggs.this
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = i.inflate(R.layout.individual_tagg_view, parent,
                    false);
            holder = new ViewHolder();
            holder.username = (TextView) convertView
                    .findViewById(R.id.userName);
            holder.review = (TextView)convertView.findViewById(R.id.review_text);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.review.setText(info.getString("review"));

        return convertView;

        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }

}

My output doesn’t output any of my Log.v statements, and doesn’t show that its even inside the GetView method.

  • 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-15T14:59:48+00:00Added an answer on May 15, 2026 at 2:59 pm
    • There is certainly something wrong
      with your Adapter. You should never
      save Views that should displayed in a
      ListView on your own. Only save the
      data that is needed to create the
      View and overwrite the getView method
      of your Adapter to create the needed
      view.

    • The second thing is the list that you
      are using in the background task is
      visible in the scope of the
      doInBackground method only. No change
      to this list can have an effect on
      your UI.

    • You are passing the JsonArray to your Adapter before starting the background thread. If your Adapter would be working correctly the ListView should be fully functional before the background thread even starts working. You should pass an empty JsonArray into the ListView and if you are extending an ArrayAdapter you can use addItem in your publish progress method.

    Some a little bit unrelated things about the naming of your Adapter class. You called it createSpecialAdapter. This sounds like a method name but it is a classname. Try to start all class names with an uppercase letter and give them names of the things they represent like SpecialAdapter.

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

Sidebar

Related Questions

I am trying to programatically add items to a ListView in WPF. I have
I have a list of items in one view controller. I can select an
Im trying to add a list view to my activity. Here is what is
I am trying to insert list items dynamically into the list view. As list
I am trying to search through items in listview control in vb.net one by
I am trying to add items to a listView that has 2 columns. When
I'm trying to add an animation to my ListView so text will fade into
i'm trying to add a contextual action mode to a listview, but i'm having
I'm trying to add a RelativeLayout, that contains 2 TextViews, above a ListView as
Trying to add a 'box' to a form at design time, I looked up

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.