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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:37:25+00:00 2026-06-01T21:37:25+00:00

have been sitting with this problem for a few days and really can’t seem

  • 0

have been sitting with this problem for a few days and really can’t seem to find the answer myself.

I’m building an application for Android devices. The application will use a socket connection to a PC running a piece of software. The user have some buttons and stuff to change the state of the PC program – this part works well. Basicly by sending text to the PC using the socket.

I also want the Android application to handle incomming events from the PC. These events should alter the UI on the device in order to reflect the state of the PC program.

To understand my problem I will try to explain the structure of the app.
Basicly the app have four activities:

  • A splash activity, which shows a splash screen and after a set time launches the next Activity
  • A connector activity, which have an input where the user will type in the IP of the PC. When the device connects to the PC, the PC will send an xml file to the device basicly containing the state of the program. This xml file is parsed and when parsed without errors this activity launches the next Activity.
  • The next activity is a TabActivity, creating 1 to 5 tabs, depending on the xml that was parsed. Each tab needs an activity which will handle the content for each tab. Here I have chosen to use one activity for all tabs.
  • The last activity is the content activity. This is a ListActivity. When parsing the xml, items will be created and divided into 5 categories – one tab for each of these. When a tab is selected for the first time, the content will be generated, and a ListView object created for that tab. For each item in a category I inflate a layout (xml) and sets the correct graphics based on the state of the object. This works just fine. Switching between the tabs is fine aswell.

So – when switching tabs I check if the ListView for the tab is null, and if that is the case I will create the content, and if not then I will call the “setListAdapter(…)” with the correct “list.getAdapter()”, where list will be the list related to the tab.

When receiving an event from the PC i have a Handler taking care of the event. This handler will parse the message, and find out what part of the UI to change, and what Object is related to this part of the UI. Then the state of the Object is changed to matter what – and if the obecjt’s tab is currently open the View is changed aswell – if another View is opened a boolean will tell that an object in the tab has changed state.

I have tried to get the View from the ListView variable and change the child elements, but this do not work when the list is not the current list.

Then I tried to create a whole new ListView for the tab when the tab is getting pressed, if this boolean shows that something have been changed (just as it’s created in the first place the first time) – this only works for one tab.

I’ve tried to test it with two of the tabs (2 and 3). The app starts on tab 1. If I then open tab 2 and then 3, sends commands to the PC from both tabs and all is fine. When the PC sends events to the app then only tab 3 will actually update. Working both when the tab is active and inactive (updates when getting active). While tab 2 does not update content on any changes.

If I only open tab 2 and not tab 3, then tab 2 will update in both cases just fine.

Anyone have any ideas to what can be done here?

I have tried all kinds of stuff with invalidate(), notifyDataSetChanged(), invalidateViews() etc, and nothing does the trick.

I really don’t understand why, when creating a whole new ListView (from changed objects) that the old ListView will still be shown.

Did I shoot myself in the foot when choosing to use one activity for all tabs, or is this something else?

Hope someone can help me here.

And if some code is needed then please tell which part, as the app consist of ~15 classes and thousands of code lines, so I won’t post it all 🙂

Cheers

  • 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-01T21:37:27+00:00Added an answer on June 1, 2026 at 9:37 pm

    I ended up with one activity for each tab content instead of the first approach where I had one Activity for them all and just switching between adapters for the listview when a tab was pressed.

    Splitting it into an activity for each tab made it possible for all content to be changed no matter if the activity was showing or not.

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

Sidebar

Related Questions

I've been driving myself crazy over the past few days over this one. We've
I have been trying to work out the bug on this but can't seem
I've been pulling my hear out over this problem for a few hours yesterday:
I have been struggling with this problem for a while now. I have a
I have been learning GWT and Hibernate together for the last few weeks and
Been sitting here for hours now trying to figure this out, so a bit
I have a problem (or maybe a discussion). I've been surfing the Internet in
I'm nearly finished with this project but I have been beating my head against
I have been struggling with Isotope for a while now. After a few different
I have been setting up an IP blocklist reciently and I was wondering is

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.