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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:06:03+00:00 2026-06-05T02:06:03+00:00

Why Listview repeats last entry on back click??????First time when that class launched with

  • 0

Why Listview repeats last entry on back click??????First time when that class launched with ListView, all the data It is showing is correct, now I click on one of the list Item and again press back from description, then It repeats the last entry.

e.g.

ListItems are:
A -> B -> C

Now I click on B and go to the next page and from that I click on back, then the list is:

A -> B -> C -> C

and again when I press A and from that A description page, when I click back, then the list is:

A -> B -> C -> C -> C

why it is repeating the last entry????

The activity class code is as follow:

         if(list.isEmpty())
                            {
                                if(adapter==null)
                                {
                                        adapter=new MyAdapter(context, list);
                                        ls.setAdapter(adapter);
                                }
                                adapter.notifyDataSetChanged();
                            }

     @Override
protected void onStop() {
    super.onStop();
   AppointmentListView.setVisibility(View.GONE);
}

@Override
protected void onRestart() {
    super.onRestart();
    AppointmentListView.setVisibility(View.VISIBLE);
} 

and MyAdapter class is:

public class MyAdapter extends BaseAdapter{

        public ArrayList<HashMap<String,String>> list;  
        Context context; 
        private LayoutInflater mInflater;
        String appointType;


        public MyAdapter(Context context, ArrayList<HashMap<String,String>> list)
        {  
            super();  
              this.context=context;
            this.list = list;  
            mInflater = LayoutInflater.from(context);

        } 

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return list.size(); 
        }
        @Override
        public int getViewTypeCount()
        {
            return 1;

        }



        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return list.get(position);
        }

        @Override
        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return position;
        }

        static class ViewHolder {  
            TextView AppTime_List;  
            TextView CustomerName_List;  
            TextView CustomerAddress_List;  
            TextView AppID_List;
            Button MapButton;
            }


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

            ViewHolder holder;  

            if (convertView == null)  
            {  
                holder = new ViewHolder();  
            convertView = mInflater.inflate(R.layout.listviewsample, parent, false);  

            holder.AppTime_List = (TextView) convertView.findViewById(R.id.time);
            holder.CustomerName_List = (TextView) convertView.findViewById(R.id.name);
            holder.CustomerAddress_List = (TextView) convertView.findViewById(R.id.Address);
               convertView.setTag(holder);

            }  
            else  
            {  
            holder = (ViewHolder) convertView.getTag();

            }  

            appointType=(String)list.get(position).get("Name");

            holder.AppID_List.setText((String)list.get(position).get("ID"));
            holder.AppTime_List.setText((String)list.get(position).get("Time"));
            holder.CustomerName_List.setText((String)list.get(position).get("Name"));
            holder.CustomerAddress_List.setText((String)list.get(position).get("Address"));



            return convertView;  

        }


    }

Can anybody pls help me on that??

  • 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-05T02:06:04+00:00Added an answer on June 5, 2026 at 2:06 am

    here the problem is with MyAdapter getCount method. now in my MyAdapter class, I have declare list_size at the top:

     int list_size;
    
      public MyAdapter(Context context, ArrayList<HashMap<String,String>> list)
    {  
        super();  
          this.context=context;
        this.list = list;  
        mInflater = LayoutInflater.from(context);
        list_size=list.size();
    
    } 
    
      @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return list_size();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF ListView which repeats the data vertically. I cannot figure out
I have created custom listview in that have list of textview & list of
I build a coustom listview, wich filled with data from SQLite. Now I want
I have a ListView that shows a list of search results. To make things
Listview has a data-inset property to make its corners rounded. However, I can't use
$(#listView object.modal).click(function(){ // Get the ID of the clicked link: var link = $(this).closest(h2).attr(title);
In listview im showing product information .On each row there is one select button
For my ListView I'm using listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new ModeCallback()); private class ModeCallback implements ListView.MultiChoiceModeListener {
I have a ListView that contains 3 checkboxes per row. I want to set
I have some kind ListView. All items in it are in rectangle shape, but

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.