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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:31:01+00:00 2026-06-12T11:31:01+00:00

I have a ListView in which I inflate 4 different layouts dynamically. In every

  • 0

I have a ListView in which I inflate 4 different layouts dynamically. In every Item in listview the common things are 3 buttons. Like ,dislike, comment. So when we click on like it shows up with gallery with profile pictures related to like. And same way for dislike and comment.
The problem arises that when I click on like it will show up proper data but when I scroll down and when that Item is out of view then when i scroll back up to view that Item it changes its view with some other button click.
This happens foe every Item in ListView
Need a urgent help
Code of getView:

@Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        mInflater= LayoutInflater.from(mContext);
            pos=position;
        if(convertView==null){
            Log.e("--------Inside---------", "convertView==null");
            holder= new Holder();
            convertView = mInflater.inflate(R.layout.custom_stream_list, null);
            holder.childView= (LinearLayout) convertView.findViewById(R.id.view_to_inflate);
            holder.myGallery= (Gallery) convertView.findViewById(R.id.myGallery_stream);
            holder.like= (ImageView) convertView.findViewById(R.id.like_stream);
            holder.dislike =(ImageView) convertView.findViewById(R.id.dislike_stream);
            holder.comment = (ImageView) convertView.findViewById(R.id.comment_stream);
            holder.commentLayout = (RelativeLayout) convertView.findViewById(R.id.comment_view_to_inflate);
            holder.comment_name = (TextView) convertView.findViewById(R.id.comment_name);
            holder.comment_description = (TextView) convertView.findViewById(R.id.comment_description);
            holder.comment_time = (TextView) convertView.findViewById(R.id.comment_time);

            convertView.setTag(holder);
        }else {
            Log.e("--------Inside---------", "else Statement");
            holder= (Holder) convertView.getTag();
        }
        holder.myGallery.setVisibility(View.INVISIBLE);

        holder.like.setTag(holder);
        holder.dislike.setTag(holder);
        holder.comment.setTag(holder);



        holder.myGallery.setSpacing(5);


        holder.like.setOnClickListener(this);
        holder.dislike.setOnClickListener(this);
        holder.comment.setOnClickListener(this);


        if((position%4)==0){
            Log.e("--------Inside---------", "position==0");
            followLayoutView = mInflater.inflate(R.layout.abc, null);
            holder.news_titile=(TextView) followLayoutView.findViewById(R.id.news_article_titile);
            holder.news_description= (TextView) followLayoutView.findViewById(R.id.news_article_description);
            holder.childView.removeAllViews();
            holder.childView.addView(followLayoutView);

        } if((position%4)==1){
            Log.e("--------Inside---------", "position==1");
            followLayoutView1 = mInflater.inflate(R.layout.xyz, null);
            holder.match_event_title= (TextView) followLayoutView1.findViewById(R.id.match_events_stream_titile);
            holder.match_event_time= (TextView) followLayoutView1.findViewById(R.id.following_time);
            holder.match_event_description= (TextView) followLayoutView1.findViewById(R.id.match_events_stream_description);
            holder.childView.removeAllViews();
            holder.childView.addView(followLayoutView1);


        } if((position%4)== 2){
            Log.e("--------Inside---------", "position==2");
            followLayoutView2 = mInflater.inflate(R.layout.pqr, null);
            holder.match_event_title= (TextView) followLayoutView2.findViewById(R.id.match_events_stream_titile);
            holder.match_event_time= (TextView) followLayoutView2.findViewById(R.id.following_time);
            holder.match_event_description= (TextView) followLayoutView2.findViewById(R.id.match_events_stream_description);
            holder.childView.removeAllViews();
            holder.childView.addView(followLayoutView2);

        } if((position%4)==3){
            Log.e("--------Inside---------", "position==3");
            followLayoutView3 = mInflater.inflate(R.layout.mno, null);
            holder.video_background= (ImageView) followLayoutView3.findViewById(R.id.video_background);
            holder.play = (ImageView) followLayoutView3.findViewById(R.id.video_play);
            holder.childView.removeAllViews();
            holder.childView.addView(followLayoutView3);


        }

        return convertView;
    }
  • 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-12T11:31:02+00:00Added an answer on June 12, 2026 at 11:31 am

    I guess you are not using Holder for your dynamic list.
    Use Holder Pattern in order to avoid that issue.
    Hope this link helps.
    http://www.vogella.com/articles/AndroidListView/article.html

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

Sidebar

Related Questions

This is a very common scenario: displaying images in a ListView which have to
I have a problem with listview which list item contain a checkbox. When i
I have listView in which I inflate a row contain textview and button now
I have a ListView in which each item has a SeekBar. When I update
I have a ListView which displays in every row an image pulled from the
I have a ListView with different layouts for different items. Some items are separators.
I have got ListView with a custom Adapter. Every row contains clickable buttons and
I have ListView which is saving all data to database. For adding i have
I have a ListView which displays a list of string values. I want to
I have a ListView which might contains a lot of items, so it is

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.