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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:17:10+00:00 2026-05-15T19:17:10+00:00

I have created a listActivity with my own ListAdapter. The problem is that the

  • 0

I have created a listActivity with my own ListAdapter. The problem is that the list is viewed in order once launched. But When I scroll down, or go back from another activity, the listView is completely out of order.

I thought the problem was in ArrayList but no, the list is sorted and i’m sure of it because when I loop over all elements in the ArrayList they are printed in the log the same way I inserted them.

I pasted the adapter code below in case anyone would like to check it.

package com.anubis.mail;

import java.util.ArrayList;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;


public class EmailAdapter extends BaseAdapter {

    private ArrayList<EmailModel> elements;
    private Context c;

    public EmailAdapter(Context c, ArrayList<EmailModel> Emails) {

        this.elements = Emails;
        this.c = c;
    }
    public int getCount() {
        return elements.size();
    }

    public Object getItem(int position) {
        return elements.get(position);
    }

    public long getItemId(int id) {
        return id;
    }

    public void Remove(int id) {
        notifyDataSetChanged();
    }

    public void Add(EmailModel email) {

        this.elements.add(email);

        for (EmailModel e : elements){

            Log.v("EmailAdapter", e.getSubject());  
        }

        notifyDataSetChanged();
    }

    public View getView(int position, View convertView, ViewGroup parent) {

        LinearLayout rowLayout;
        EmailModel email = elements.get(position);

        if (convertView == null) {

            rowLayout = (LinearLayout) LayoutInflater.from(c).inflate (R.layout.inbox_item, parent, false); 

            TextView subject_textview = (TextView)rowLayout.findViewById(R.id.subject_textview);
            subject_textview.setText(email.getSubject());

            String body_hint = " - " + email.getBodyHint();

            TextView bodyhint_textview = (TextView)rowLayout.findViewById(R.id.body_hint_textview);
            bodyhint_textview.setText(body_hint);


            String sender_name = get_sender_name(email.getSender());

            TextView sender_name_textview = (TextView)rowLayout.findViewById(R.id.sender_textview);
            sender_name_textview.setText(sender_name);

            TextView date_time_textview = (TextView)rowLayout.findViewById(R.id.date_time_textview); 
            date_time_textview.setText(email.getTime());

        } else {
            rowLayout = (LinearLayout) convertView;
        }
        return rowLayout;
    }

    private String get_sender_name(String from) {

        String[] sender = from.split("<");
        String sender_name;

        try {
            sender_name = sender[0];
        } catch (Exception e) {
            sender_name = sender[1];
        }
        return sender_name;
    }
}
  • 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-15T19:17:11+00:00Added an answer on May 15, 2026 at 7:17 pm

    You need to move code after the IF

    if (convertView == null) {
            rowLayout = (LinearLayout) LayoutInflater.from(c).inflate (R.layout.inbox_item, parent, false); 
    } else {
            rowLayout = (LinearLayout) convertView;
    }
    TextView subject_textview = (TextView)rowLayout.findViewById(R.id.subject_textview);
    subject_textview.setText(email.getSubject());
    
    String body_hint = " - " + email.getBodyHint();
    
    TextView bodyhint_textview = (TextView)rowLayout.findViewById(R.id.body_hint_textview);
    bodyhint_textview.setText(body_hint);
    
    
    String sender_name = get_sender_name(email.getSender());
    
    TextView sender_name_textview = (TextView)rowLayout.findViewById(R.id.sender_textview);
    sender_name_textview.setText(sender_name);
    
    TextView date_time_textview = (TextView)rowLayout.findViewById(R.id.date_time_textview); 
    date_time_textview.setText(email.getTime());
    return rowLayout;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom ListActivity that shows a list of skills and buttons
I have created a ListActivity in which I am showing some data ,but after
I have following goal: From a list in main activity that extends ListActivity, I
I'm creating a ListActivity. In each list item I have a View I've created
I have created a PHP-script to update a web server that is live inside
I have created a UserControl that has a ListView in it. The ListView is
I have created a few small flash widgets that stream .mp3 audio from an
i have created a workflow activity that do give the item creater of a
I have a problem with my ListActivity, i use a thread to show a
I have a problem saving the list after edit the listview with drag and

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.