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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:38:47+00:00 2026-06-16T15:38:47+00:00

I have a custom listview defined in my xml layout file. I can add

  • 0

I have a custom listview defined in my xml layout file. I can add items to this ListView inside onCreate method, through an array adapter.

However when I add items from another content view and then go back to the content view with the ListView all the items are gone and there’s nothing listed. Even after calling .notifyDataSetChanged();

It seems like I can only add to the list when the content view containing the ListView is currently being displayed. Is this the default behavior?

Failed attempted workaround

I used another array to keep the newly added items and then try to add them when the ListView became visible again. I had to override onContentChanged() to do so but then no items were added still.

So the main question is

How can I dynamically add items to the ListView even if it’s out of sight and still preserve the old items?

PS: I have to say the Android API is one of the worst I’ve ever come across.

  • 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-16T15:38:50+00:00Added an answer on June 16, 2026 at 3:38 pm

    If you change content view, then all the previous views are going to be destroyed. Are you using an adapter? If so, then it would be very easy to add all the items to the list again.

    There shouldn’t be any reason to setContentView any time other than in onCreate.

    If you were looking to have multiple screens, instead of changing content view, then start a new activity.

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

Sidebar

Related Questions

I have a listView with custom objects defined by the xml-layout below. I want
I have a custom listview with three items. One of them is like Add
I have a Custom ListView created from XML Layout. I want to bind that
I have an activity with a listView, which uses a custom row layout defined
I have a custom listView defined like this public class DDListView extends ListView implements
I have created custom listview, each row looks like my file custom_row.xml. Is there
I am populating the ListView from my Custom DataAdaptor. I have a layout defined
I have a custom ListView in which each row.xml looks like this: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I have used custom listview and custom rating bar. If I add that custom
I have a custom listview and made overlapping very simple: in onDraw method, I

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.