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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:16:09+00:00 2026-05-20T00:16:09+00:00

My Activity consists of GridView which holds 40+ elements. After starting activity user could

  • 0

My Activity consists of GridView which holds 40+ elements. After starting activity user could see maximum 15 items (3 rows, 5 items in each row). I wrote in getView() body to pass to the LogCat number of getting View:

Log.i("getView()", "GETTING VIEW_POSITION[" + String.valueOf(position) + "]" + (convertView != null?convertView.toString():"null"));

After launching my app I get such log:

02-09 14:34:56.900: INFO/getView()(388): GETTING VIEW_POSITION[0]null
02-09 14:34:57.300: INFO/getView()(388): GETTING VIEW_POSITION[0]android.widget.FrameLayout@44c7a9c0  
02-09 14:34:57.300: INFO/getView()(388): GETTING VIEW_POSITION[1]null
02-09 14:34:57.400: INFO/getView()(388): GETTING VIEW_POSITION[2]null
02-09 14:34:57.510: INFO/getView()(388): GETTING VIEW_POSITION[3]null
02-09 14:34:57.620: INFO/getView()(388): GETTING VIEW_POSITION[4]null
02-09 14:34:57.720: INFO/getView()(388): GETTING VIEW_POSITION[5]null
02-09 14:34:57.840: INFO/getView()(388): GETTING VIEW_POSITION[6]null
02-09 14:34:57.930: INFO/getView()(388): GETTING VIEW_POSITION[7]null
02-09 14:34:58.273: DEBUG/dalvikvm(388): GC freed 3530 objects / 322744 bytes in 270ms
02-09 14:34:58.280: INFO/getView()(388): GETTING VIEW_POSITION[8]null
02-09 14:34:58.300: INFO/getView()(388): GETTING VIEW_POSITION[9]null
02-09 14:34:58.320: INFO/getView()(388): GETTING VIEW_POSITION[10]null
02-09 14:34:58.340: INFO/getView()(388): GETTING VIEW_POSITION[11]null
02-09 14:34:58.360: INFO/getView()(388): GETTING VIEW_POSITION[12]null
02-09 14:34:58.380: INFO/getView()(388): GETTING VIEW_POSITION[13]null
02-09 14:34:58.400: INFO/getView()(388): GETTING VIEW_POSITION[14]null
02-09 14:34:59.220: INFO/getView()(388): GETTING VIEW_POSITION[0]null
02-09 14:34:59.490: INFO/getView()(388): GETTING VIEW_POSITION[0]android.widget.FrameLayout@44c69ef0

I also red this post about such kind of issue. But My GridView’s height in XML description set as fill parent:

<?xml version="1.0" encoding="utf-8"?>

<GridView xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/grid"
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent"
                android:numColumns="auto_fit"
                android:horizontalSpacing="10dp"
                android:verticalSpacing="10dp"
                android:columnWidth="140dp"
                android:gravity="center"
                android:scrollbars="none"
                /> 

And finally to remove all doubts, here is my Adapter code:

public class ImageAdapter extends BaseAdapter
    {
        private Activity activity;
        private LayoutInflater inflater = null;
        private ArrayList<Photo> photoes;
        
        public ImageAdapter(Activity a, ArrayList<Photo> pictures)
        {
            photoes = pictures;
            activity = a;
            inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent)
        {
            Log.i("getView()", "GETTING VIEW_POSITION[" + String.valueOf(position) + "]" + (convertView != null?convertView.toString():"null"));
                View mViewSlice = convertView;
                if(convertView == null) {
                    mViewSlice = inflater.inflate(R.layout.photo_preview, null);
                    ((TextView) mViewSlice.findViewById(R.id.name_of_photo)).setText(photoes.get(position).getName());
                    
                    mViewSlice.setPadding(5, 5, 5, 5);
                    mViewSlice.setLayoutParams(new GridView.LayoutParams(-2, -2));
                    
                }
        
               
                      
               return mViewSlice;
        }

        @Override
        public int getCount() {
            return photoes.size();
        }

        @Override
        public Object getItem(int position) {
            return photoes.get(position);
        }

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

I hope somebody will respond at my problem and will help me to solve it.

Waiting for your suggestions. Alex.

  • 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-20T00:16:10+00:00Added an answer on May 20, 2026 at 12:16 am

    The response on that link if quite clear I think

    There is absolutely no guarantee on
    the number of times getView() will be
    invoked for any given position

    Now this remark also implies you shouldn’t use wrap_content

    usually occurs with lists and grids
    that have a height set to wrap_content

    But that does not mean it would not happen for other situations. The bug was closed as “WorkingAsIntended”, so I don’t think you can do too much. It’s just something that can happen.

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

Sidebar

Related Questions

I have an activity which consists of a GridView with multiple (different) images. When
I've implemented a 'home screen' for my application, which consists of a gridview containing
Im currently trying to add the SlidingDrawer in my application.. My activity consists GridView
My project consists of a single Activity so far that loads a GridView that
The basis: Activity - recreates(onCreate-onDestroy) on each orientatin change View consists of ViewFlipper with
I have 2 activities. Activity 1 is the 'Homepage' which consists of one spinner.
The activity monitor in sql2k8 allows us to see the most expensive queries. Ok,
An Activity occurs at a location on a specific date, but each activity may
I have an activity that has a TabHost containing a set of TabSpecs each
For tracking user activity, I am using a Windows Hook for the main application

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.