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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:41:29+00:00 2026-06-09T06:41:29+00:00

I have a main activity that uses a FrameLayout with the screen split into

  • 0

I have a main activity that uses a FrameLayout with the screen split into left navigation and right content panels. The left panel is used for navigation to load different layouts into the right panel (called contentLayout) which can have multiple layouts glued together. I have a ListView in the left navigation panel with onItemClickListeners. In their separate onItemClick methods, I use contentLayout.removeAllViews() and then inflate their layouts like so:

private final OnItemClickListener redListener = new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        contentLayout.removeAllViews();
        if (myFirstClassLayout == null) {
            myFirstClassLayout = FirstClassLayout.getLayout(
                                layoutInflater, 
                                MyActivity.this, 
                                resources, 
                                new ArrayList<String>(),
                                new ArrayList<Desc>()
                            );
        }
        CommonClass.updateListeners();
        if (FirstClassLayout != null) contentLayout.addView(myFirstClassLayout);
    }
};

private final OnItemClickListener blueListener = new OnItemClickListener() {
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        contentLayout.removeAllViews();
        if (mySecondClassLayout== null) {
            mySecondClassLayout = SecondClassLayout.getLayout(
                                layoutInflater, 
                                MyActivity.this, 
                                resources, 
                                new ArrayList<String>(),
                                textList,
                                new ArrayList<Desc>(),
                                hash
                            );
        }
        CommonClass.updateListeners();
        if (SecondClassLayout != null) contentLayout.addView(mySecondClassLayout);
    }
};

In both the FirstClassLayout and SecondClassLayout, I inflate a ThirdClassLayout which contains a dynamic ListView (let’s call it commonListView) that makes use of an ArrayAdapter<String>. The ListView is a listChoiceIndicatorSingle style view, meaning that it shows a radio-button-like icon to the right of each list item.

When the app starts up, the right content panel is empty. If I trigger the redListener or the blueListener, it will display the commonListView in the right content panel with none of the list items selected. If I trigger red first, then trigger blue, then make a selection in the commonListView, the change is reflected back to the FirstClassLayout which is great! However, when I continue by selecting something else in the commonListView from that FirstClassLayout, and then trigger the blueListener to go to the SecondClassLayout, the commonListView in the SecondClassLayout does not reflect the selection I just made. Instead, it is stuck on item I selected when I was last on the SecondClassLayout.

This happens if I perform the testing in the reverse order, so depending on which listener I trigger last, that last listener and layout will have proper UI synching control over both layouts. The one I trigger first seems to be able to only control itself. I need for both listeners to be able to display the exact same ListView selected item on both Layouts at any given time.

The synching of the commonListView from last layout to first layout is achieved through CommonClass.updateListeners() which does:

 adapter.clear();
 for (String title: statusSet) adapter.add(title);
 adapter.notifyDataSetChanged();
 commonListView.setItemChecked(positionOfItemChecked, true);
 Log.i(TAG, "position checked = " + positionOfItemChecked);
 adapter.notifyDataSetChanged();

Since this works from last layout triggered to first, I figure this must be related to a UI refresh problem, but I’ve searched everywhere for a good solution and tried all suggestions. The Log.i statement prints out correctly in the LogCat for first or last layout triggered, so I know it is hitting the code properly. I just don’t understand why the first one is unable to control the last one. I’ve tried:

 commonListView.invalidate();
 ((BaseAdapter) commonListView.getAdapter()).notifyDataSetChanged(); 

and AsyncTask and several others, but nothing seemed to work on refreshing the first layout so that it matches the second. Has anyone encountered such an issue? Does anyone know how to fix or get around this?

  • 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-09T06:41:30+00:00Added an answer on June 9, 2026 at 6:41 am

    I figured out what was causing the 2nd one to take hold over the 1st. I inherited a lot of this code and so I’m not familiar with all the parts. Several other pieces were involved. I finally found the portion of code where the original author used a custom AdapterWrapper that implements a custom Listener. The ThirdClassLayout was only creating a new ArrayAdapter and a new AdapterWrapper once by checking to see if the static ArrayAdapter was null. Removing this check allowed both adapter objects to be created new for both layouts. With their own Listeners created, both layouts now respond.

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

Sidebar

Related Questions

I am making an app in which i have a main activity that the
Splash I have main activity UI startup operations that take between 5-10 seconds (that
I have a widget that supposed to call an Activity of the main app
The scenario is the following: I have an activity RunTrainingWorkoutsView that uses XML layout
I am trying to debug an activity that uses the android os main search
I have work that needs to be done in this order: In main activity:
i have main activity in which i have Four menus. and i have one
I have a design of activities like this I have one main activity and
I am making an android app. I have a main activity and i want
I have a main menu activity with a bunch of buttons. One button starts

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.