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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:18:56+00:00 2026-06-07T11:18:56+00:00

I am using SimpleAdapter for displaying a ListView , but whenever I press the

  • 0

I am using SimpleAdapter for displaying a ListView, but whenever I press the back button, and open the activity (which shows the list) again, the entries of the list become double.

If I do it again, array values again concatenates with the items of the list.

List variable of array is declared as

 private static final ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>();

my code in onCreate() of List.java:

setContentView(R.layout.list);



    HashMap<String,String> temp = new HashMap<String,String>();
    temp.put("first","Strength");
    temp.put("second", strength);
    list.add(temp);


    HashMap<String,String> temp1 = new HashMap<String,String>();
    temp1.put("first","what");
    temp1.put("second", "??");
    list.add(temp1);


    HashMap<String,String> temp2 = new HashMap<String,String>();
    temp2.put("first","Time");
    temp2.put("second", "time");
    list.add(temp2);


    HashMap<String,String> temp3 = new HashMap<String,String>();
    temp3.put("first","Repeat");
    temp3.put("second", "everyday");
    list.add(temp3);




    setListAdapter(new SimpleAdapter(this,list,R.layout.row_view, new String [] {"first","second"}, new int [] {R.id.rowTextView1, R.id.rowTextView2} ));
  • 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-07T11:18:58+00:00Added an answer on June 7, 2026 at 11:18 am

    You could make an if statement to check to see if there is anything already in list or not, like this:

    if(list.size() == 0){
    
    HashMap<String,String> temp = new HashMap<String,String>();
    temp.put("first","Strength");
    temp.put("second", strength);
    list.add(temp);
    
    
    HashMap<String,String> temp1 = new HashMap<String,String>();
    temp1.put("first","what");
    temp1.put("second", "??");
    list.add(temp1);
    
    
    HashMap<String,String> temp2 = new HashMap<String,String>();
    temp2.put("first","Time");
    temp2.put("second", "time");
    list.add(temp2);
    
    
    HashMap<String,String> temp3 = new HashMap<String,String>();
    temp3.put("first","Repeat");
    temp3.put("second", "everyday");
    list.add(temp3);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on project with listview,but I have a little problem. I'm using SimpleAdapter
I have a list view that is built using a simpleAdapter, each row is
I'm using the following code to populate listview Oncreate method: SimpleAdapter adapter = new
I have an Android activity that displays a list of log entries (using a
I have a simple ListView that gets populated using an array of SimpleAdapter s.
This tutorial uses a SimpleAdapter which works fine, but I need to update the
I am using an array list, a listView, and a custom simple adapter in
I'm implementing an Android activity. I am using a ListView in my application layout,
I'm using the ListView to provide a list for the user to choose from.
I have filled the listview using the code given below, but I'm unablee to

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.