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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:19:07+00:00 2026-05-23T03:19:07+00:00

i have a gridview layout, and all items are insert very fine, now if

  • 0

i have a gridview layout, and all items are insert very fine,

now if I check on big screen then all work done is fine, because no scrolling is required

but if I check on small screen then items are changed their position dynamically,

bereif example is given below:-

like I have 28 items and arranged in a grid view 7*4, now if upto 20 items are shown in first screen, now remaining 8 is shown while i scroll screen down, but now some elements of first or second row is aslo put in last row.

code is here

public class ImageAdapter extends BaseAdapter
    {
        Context mContext;
        //public static final int ACTIVITY_CREATE = 10;
        public ImageAdapter(Context c)
        {
            mContext = c;
        }
        @Override
        public int getCount() 
        {
            // TODO Auto-generated method stub
            return providers.length;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) 
        {
            // TODO Auto-generated method stub
            View v;
            if(convertView==null)
            {
                LayoutInflater li = getLayoutInflater();
                v = li.inflate(R.layout.icontext, null);
                TextView tv = (TextView)v.findViewById(R.id.icon_text);
                tv.setText(providers[position]);
                ImageView iv = (ImageView)v.findViewById(R.id.icon_image);
            iv.setImageResource(R.drawable.icon);
            }
            else
            {
                v = convertView;
            }
            return v;
        }
  • 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-23T03:19:07+00:00Added an answer on May 23, 2026 at 3:19 am

    You should change your getView method like this.

        public View getView(int position, View convertView, ViewGroup parent){
            // TODO Auto-generated method stub
            View v;
            if(convertView==null)
            {
                LayoutInflater li = getLayoutInflater();
                v = li.inflate(R.layout.icontext, null);
            }else{
                v = convertView;
            }
            TextView tv = (TextView)v.findViewById(R.id.icon_text);
            tv.setText(providers[position]);
            ImageView iv = (ImageView)v.findViewById(R.id.icon_image);
            iv.setImageResource(R.drawable.icon);
    
            return v;
        }
    

    Your problem is that when you use convertView it stores old data form the first records. Convert view is used to avoid layout inflation from resource which costs you time and memory. You should use the old inflated view, but set new data.

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

Sidebar

Related Questions

I currently have a GridView scrolling vertically, and everything works fine. But now that
What I've Done I have created a GridView in my layout. This GridView I'd
I have GridView which I can select a row. I then have a button
I have a GridView populated from an ObjectDataSource with two items in its DataKeyNames
I have GridView bound to some List. In layout I created following template field:
I have a GridView that displays several dozen rows worth of a custom layout,
I have a GridView that is created based on an array of items. I
I would actually love to have an AlternatingItemTemplate on a GridView, but all it
hi i have create one simple media player.... now its working fine. i retrieve
I have a GridView with 9 items. What I'm trying to do is when

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.