Reputation: 97
I'm developing an application that have an activity Group inside a tabhost., so i have working s stack of activities inside the same tab.
The problem emerges when i try the search interface and inside this tab and nothing happens, if I launch the search Interface in another activity works normally".
Also, if I try to to execute a method from the layout xml with the "onClick" option the app crashes
01-06 10:09:24.533: E/AndroidRuntime(1404): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@40538fa0 is not valid; is your activity running?
01-06 10:09:24.533: E/AndroidRuntime(1404): at android.view.ViewRoot.setView(ViewRoot.java:562)
01-06 10:09:24.533: E/AndroidRuntime(1404): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
01-06 10:09:24.533: E/AndroidRuntime(1404): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
01-06 10:09:24.533: E/AndroidRuntime(1404): at android.view.Window$LocalWindowManager.addView(Window.java:433)
01-06 10:09:24.533: E/AndroidRuntime(1404): at android.app.Dialog.show(Dialog.java:265)
01-06 10:09:24.533: E/AndroidRuntime(1404): at android.app.DatePickerDialog.show(DatePickerDialog.java:132)
01-06 10:09:24.533: E/AndroidRuntime(1404): at android.app.Activity.showDialog(Activity.java:2727)
01-06 10:09:24.533: E/AndroidRuntime(1404): at android.app.Activity.showDialog(Activity.java:2685)
I also noted that if i intent to display a dialog inside this ActivityGroup crashes, but i overlap this issue getting the the context of the parent activity to display it.
m_ProgressDialog = ProgressDialog.show(getParent(), "Please wait", "Downloading info", true,false);
instead
m_ProgressDialog = ProgressDialog.show(this, "Please wait", "Downloading info", true,false);
It could something to have a nested class?
Greetings
Upvotes: 0
Views: 771
Reputation: 51
do
View viewToLoad = LayoutInflater.from(this.getParent()).inflate(R.layout.your_id, null);
setContentView(viewToLoad);
Remove the onClick method in the xml file and put a onClickListener on the button in java code. This will do the job ;)
Upvotes: 0
Reputation: 3911
I guess you're using
setContentView(R.layout.your_id);
which causes the COntext Problems in the ActivityGroup.
Try using it this way:
View viewToLoad = LayoutInflater.from(this.getParent()).inflate(R.layout.your_id, null);
setContentView(viewToLoad);
And as a short note: You should maybe switch to fragments, because ActivityGroups are deprecated. They make a lot of trouble ...
Upvotes: 1