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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:25:50+00:00 2026-05-18T02:25:50+00:00

In my application I have a Tabbar and I am using ActivityGroup to load

  • 0

In my application I have a Tabbar and I am using ActivityGroup to load contents into each tab as shown below.

public class FirstGroup extends ActivityGroup {

        // Keep this in a static variable to make it accessible for all the nesten activities, lets them manipulate the view
 public static FirstGroup group;

        // Need to keep track of the history if you want the back-button to work properly, don't use this if your activities requires a lot of memory.
 private ArrayList<View> history;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       this.history = new ArrayList<View>();
       group = this;

              // Start the root activity withing the group and get its view
       View view = getLocalActivityManager().startActivity("FlightsActivity", new
                   Intent(this,FlightsActivity.class)
                   .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
                                      .getDecorView();

              // Replace the view of this ActivityGroup
       replaceView(view);

    }

 public void replaceView(View v) {
                // Adds the old one to history
  history.add(v);
                // Changes this Groups View to the new View.
  setContentView(v);
 }

i have an image inside the FlightsActivity activity class and on the onClick event of the image I need a datepicker to be displayed.I have written the code for that and it was working fine when I was directly specifying FlightsActivity as the content of the tab instead of loading it through the ActivityGroup.But now i am getting an error

10-20 14:11:16.302: ERROR/AndroidRuntime(294): FATAL EXCEPTION: main
10-20 14:11:16.302: ERROR/AndroidRuntime(294): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@43e497e0 is not valid; is your activity running?
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at android.view.ViewRoot.setView(ViewRoot.java:505)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at android.app.Dialog.show(Dialog.java:241)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at android.app.DatePickerDialog.show(DatePickerDialog.java:129)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at android.app.Activity.showDialog(Activity.java:2556)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at android.app.Activity.showDialog(Activity.java:2514)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at tabviewapp.com.FlightsActivity$10.onClick(FlightsActivity.java:166)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at android.view.View.performClick(View.java:2408)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at android.view.View$PerformClick.run(View.java:8816)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at android.os.Handler.handleCallback(Handler.java:587)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at android.os.Looper.loop(Looper.java:123)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at android.app.ActivityThread.main(ActivityThread.java:4627)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at java.lang.reflect.Method.invokeNative(Native Method)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at java.lang.reflect.Method.invoke(Method.java:521)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-20 14:11:16.302: ERROR/AndroidRuntime(294):     at dalvik.system.NativeStart.main(Native Method)

Below is my code for implementing the datepicker:

mPickDate = (ImageView) findViewById(R.id.pickDate);
  mPickDate.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
             showDialog(DATE_DIALOG_ID);
            }
        });

@Override
 protected Dialog onCreateDialog(int id) {
     switch (id) {
     case DATE_DIALOG_ID:
         return new DatePickerDialog(this,
                     mDateSetListener,
                     mYear, mMonth, mDay);
     case DATE_DIALOG_ID_RETURN:
         return new DatePickerDialog(this,
           mDateSetListenerreturn,
                     mYear, mMonth, mDay);     
     }
     return null;
 }

 // updates the date in the TextView
    private void updateDisplay(TextView mDateDisplay) {
        mDateDisplay.setText(
            new StringBuilder()
                    // Month is 0 based so add 1
                   .append(mDay).append("-")
                   .append(mMonth + 1).append("-")
                   .append(mYear).append("")


                    );
    }
    private DatePickerDialog.OnDateSetListener mDateSetListener =
        new DatePickerDialog.OnDateSetListener() {

            public void onDateSet(DatePicker view, int year, 
                                  int monthOfYear, int dayOfMonth) {
                mYear = year;
                mMonth = monthOfYear;
                mDay = dayOfMonth;
                updateDisplay(mDateDisplay);
            }
        };

        private DatePickerDialog.OnDateSetListener mDateSetListenerreturn =
            new DatePickerDialog.OnDateSetListener() {

                public void onDateSet(DatePicker view, int year, 
                                      int monthOfYear, int dayOfMonth) {
                    mYear = year;
                    mMonth = monthOfYear;
                    mDay = dayOfMonth;
                    updateDisplay(mDateDisplayreturn);
                }
            };
  • 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-05-18T02:25:51+00:00Added an answer on May 18, 2026 at 2:25 am

    Try this to display your context:

    Instead of :

    setContentView(R.layout.xyz);
    

    Use this:

    View viewToLoad = LayoutInflater.from(this.getParent()).inflate(R.layout.xyz, null);
    this.setContentView(viewToLoad );       
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tabbar application with each tab directing user to a UITableViewController. I
I have an iOS 5 Tabbed Application, using Storyboards. My Tabbar Controller points to
I have a tabbar application. And the item of first tab is Navigation Controller.
I have a multiview application using a tab bar to switch views. One is
I have created a custom tabbar in my application (using TabHost and TabWidget ).
I want to make an application which has Tab bar . In each TabBar
I have an application that has many views (Using tab bar controller). I want
I have used tabbar with activity group in my application. I have four tab
in my application i have to make settings button in tabbar .so using this
I have created a Tabbar Application using Xcode. I have 5 different tabs and

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.