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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:42:27+00:00 2026-05-31T21:42:27+00:00

HI Guyz i have created a sectioned custom listview using baseadapter its working fine

  • 0

HI Guyz i have created a sectioned custom listview using baseadapter its working fine but there is only one problem when i scroll it again and again it get crashed and give memory out exception. i am posy my getview() code plz help me.

    @Override
public View getView(final int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub

    View row = convertView;

    Image cached = images[position];
    boolean flag = cached.sender_user;
    // System.out.println("Timeline: Position: "+position+", Length: "+data.length);
    // if(position!=data.length-1){
    System.out.println(position + " ===== " + images[position].pic_url);

    if (cached.sender_user == false) {
        System.out.println("If");

        row = vi.inflate(R.layout.list_row_layout_sender, null);
        txt_msg = (TextView) row.findViewById(R.id.txt_msg);
        txt_name = (TextView) row.findViewById(R.id.txt_name);
        txt_time = (TextView) row.findViewById(R.id.txt_time);
        img = (ImageView) row.findViewById(R.id.user_img);


        btn_loc=(Button)row.findViewById(R.id.btn_loc);
        btn_loc.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                System.out.println("-------------- btn_loc ------------------- Sender");
                Developer.callIntent_userlocation(context, "18.50929796 ", "73.79045371");
            }
        });
        txt_name.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                System.out.println("----Name----");

                Developer.callIntent(context,images[position].id);
            }
        });
        img.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                System.out.println("----Image----");
                Developer.callIntent(context,images[position].id);
            }
        });
        txt_name.setText(cached.sender_name);
        txt_time.setText(cached.time);
        txt_msg.setText(cached.messege);
        if (position != 0) {
            cached = images[position - 1];
            if (cached.sender_user == flag) {
                img.setVisibility(ImageView.INVISIBLE);
                txt_name.setVisibility(TextView.INVISIBLE);
            } else
                imageLoader.DisplayImage(images[position].pic_url.trim()
                        .replace(" ", "%20"),
                        ReadMessageActivityNew.activity, img);
        } else
            imageLoader.DisplayImage(images[position].pic_url.trim()
                    .replace(" ", "%20"), ReadMessageActivityNew.activity,
                    img);
        System.out.println("Downloading=> for Reciver" + cached.pic_url);
        return row;
    }

    else {

        System.out.println("Else");

        row = vi.inflate(R.layout.list_row_layout_receiver, parent, false);
        txt_msg = (TextView) row.findViewById(R.id.txt_msg);
        txt_name = (TextView) row.findViewById(R.id.txt_name);
        txt_time = (TextView) row.findViewById(R.id.txt_time);
        img = (ImageView) row.findViewById(R.id.user_img);
        btn_loc=(Button)row.findViewById(R.id.btn_loc);

        btn_loc.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                System.out.println("-------------- btn_loc ------------------- Reciever");


                Developer.callIntent_userlocation(context, "18.50929796 ", "73.79045371");
            }
        });
        txt_name.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Developer.callIntent(context, images[position].id);
            }
        });
        img.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub


                Developer.callIntent(context, images[position].id);
            }
        });
        txt_name.setText("Me");
        txt_time.setText(cached.time);
        txt_msg.setText(cached.messege);
        if (position != 0) {
            cached = images[position - 1];
            if (cached.sender_user == flag) {
                img.setVisibility(ImageView.INVISIBLE);
                txt_name.setVisibility(TextView.INVISIBLE);
            } else
                imageLoader.DisplayImage(images[position].pic_url.trim()
                        .replace(" ", "%20"),
                        ReadMessageActivityNew.activity, img);
        } else
            imageLoader.DisplayImage(images[position].pic_url.trim()
                    .replace(" ", "%20"), ReadMessageActivityNew.activity,
                    img);

        System.out.println("Downloading=> for User" + cached.pic_url);
        return row;
    }

}
  • 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-31T21:42:28+00:00Added an answer on May 31, 2026 at 9:42 pm

    The problem is that you’re creating a new View every time this method is called. You only need to inflate a View from a layout if convertView is null. If convertView is not null then it’s a view that has been recycled for you to use.

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

Sidebar

Related Questions

ok guyz, got one more question for you. i need to select only the
Hi guyz im able to pinch zoom the image in webview its working properly.
Would you guyz be so kind to help me with such question: I have
hi guyz i know android says if u are working with gui adjust your
Hi guyz I'm trying to implement the InnerFade JQuery on my page but I'm
I have created a function which will convert any string into tab delimited. What's
I have migrated an app from a full-Hibernate featured one to a JPA/Hibernate based-one
hai guyz, how can i send AT-command through bluetooth from a python application? OS:fedora
I've got confused at the moment. I've got one database to developed for MLM
I am building a client server application using Java Sockets (in Windows XP). For

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.