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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:27:46+00:00 2026-05-26T23:27:46+00:00

Tried using the following: Populate Listview from JSON To make a listview which uses

  • 0

Tried using the following:

Populate Listview from JSON

To make a listview which uses a JsonArray containing Json Objects. For some reason, the
‘public View getView(int position, View convertView, ViewGroup parent)’
code is fired more times than there are contents in the jsonarray.

I made a control test to check up on this and I found that even with just 1 Jsonobject within the jsonarray, I came up with 32 times the getView code was activated.

I am rather confused as to why this is happening, as my friends have managed to make similar codes to mine, but without the huge number of activations I am suffering from. Am I being rather slow, and this is because the individual Jsonobject has, not only the image and text in them, but about 15 other items within it? Or is ther another cause?

I would appreciate any aid towards this, I am posting the adapter code below:

    public class ArticleAdapter extends BaseAdapter{

    private JSONArray items;
    private Context cont;
    public ArticleAdapter(Context context, JSONArray array)
    {
        super();
        this.items = array;
        this.cont = context;
    }

    @Override
    public int getCount() {
        return items.length();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;

    }@Override
    public View getView(int position, View convertView, ViewGroup parent) 
    {
        View v = convertView;
        WebIView sath;
        TextView sati;
        Log.i("Seiji", "Checking! " + position);
        try
        {       
            if(!items.isNull(position))
            {
                JSONObject item = items.getJSONObject(position);
                if (v == null) {
                    v = LayoutInflater.from(cont).inflate(R.layout.saved_articles_listitem, null);
                }           
                sath = (WebIView) v.findViewById(R.id.sathumbnail);
                sati = (TextView) v.findViewById(R.id.satitle);

                if(item.has("image") && sath != null)
                {
                    JSONObject thisImage = item.getJSONObject("image");
                    sath.reset();
                    sath.setImageUrl(thisImage.getString("thumbnail"));
                    sath.loadImage();
                }
                if(sati != null)
                {
                    sati.setText(item.getString("title"));
                }
            }else{
                return null;
            }
        }
        catch(Exception e)
        {
            Log.e("num", "Saved Art Error! " + e.toString());
        }
        return v;
    }
}

the code which activates this class is the following:

ListView savedArtList = (ListView) sav.findViewById(R.id.savelist);
ArticleAdapter savedadapter = new ArticleAdapter(cont, flip);
ArtList.setAdapter(savedadapter);

EDIT:

Thanks to some very helpful advice I was able to figure out what was going wrong. The Listview was resizing itself every time a new row was added because I had set the views height to be ‘wrap_content’. I hadnt realised that this would cause problems, but once I had set it to ‘fill_parent’ (or a set value in other cases), the issue disappeared and I didnt have this problem any more.
Thank you againfor the helpful advice!

  • 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-26T23:27:46+00:00Added an answer on May 26, 2026 at 11:27 pm

    getView will be called many times – per visible cell when the list view is being laid out, per visible cell when the list view is being drawn + more. This is normal behaviour and getView should be efficient. Its possible your images and/or text are making the height of each cell change as they’re loaded in, meaning other cells may become visible / go off screen etc.

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

Sidebar

Related Questions

I have a bunch of dropdownlists which I populate from an xml file using
I have tried using the obvious method as outlined in the following example but
I tried using "cap rollback" but I get the following error: $ cap rollback
I tried to modify a type using the following code and it gave me
I tried to reuse the .pch to speed the build using the following way:
Has anyone ever tried sending emails using 1&1 smtp host? I tried the following?
I tried installing TurboGears 1.0 on Windows 7 using tgsetup.py. and got following error
How do you rotate an image using jQuery-rotate plugin? I have tried the following
I'll point out now, that I'm new to using saxon, and I've tried following
Following is the code to populate combobox using DataSource Dim CountryList As Array =

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.