Android Dialog problem with TabView - android

My problem is when a dialog is opened, if I change the tab, that dialog is displayed in the activity in the next tab.How to remove that .
Pls help.
This occurs because according to my requirement I can interact with the dialog and the view behind at the same time.

I resolved it by dismissing the dialog in onPause() method

You should check if the dialog is open or not on the click of another tab, if open close it.

You have a tabhost and a framelayout... just identify the tab changed via calling OnTabChangedListener and perform frameLayout.removeAllView(); and then render a dialog again.. I think it may help...!! if not then can u please describe ur problem in brief...

Related

How to restrict from user to be able to click on activity before clicking on dialog on Android?

So i have one simple dialog thats starts when activity is created, but when i click besides the dialog it is closed and activity is shown. I would like to disable the activity until the user click the button on dialog box. Can you give me some ideas?
Thanks in advance
Please set this-
dialog.setCancelable(false);

Want to show alert dialog across activities

I want to show an Alert Dialog such that it stays on screen even if I go back to previous activity just after showing an alert dialog. Is is possible?
I tried using applicationContext but it does not work.
I don't think so, and I believe this would be a bad user experience. Perhaps you should re-think the design.
You cant do that , because a dialog is attached with a single window context , if window changes the dialog memory will be leaked and it will automatically close the dialog .You can make a same effect by showing the same dialog in both screens .However you will definitely see the transition of dialog with activity .
You can create an activity and give it a dialog theme. That way you dont have to worry about the context. It doesnt make a difference to the user also as it looks just like a dialog.
But I agree with AndyRes, It would be a bad user experience.

Android toast appearing in each tab

I currently have a tabview and in my first tab i have a toast message that appears. If click on another tab while the toast is still displaying, it will display in that tab as well. Is there any way to not make this happen? Do i simply cancel it inside the onPause()? thanks for your help
You could detect tab change and cancel it in that method. For tab change help - Android TabWidget detect click on current tab
Toast's are not tied with any particular activity as they are an overlay over the screen. If you want to explicitly close the Toast, you need to pass a handle of it to whichever activity needs to close it and call Toast.cancel().
Yeah you can simply call cancel() in onPause() of the activity that has created it.

How to navigate between Tabs in android

I have created a TabActivity in my android application. When user selects the second tab, an alert dialog will appear. Is there any way to navigate to the previous tab when user clicks the cancel button for the dialog box.
regards
dj
I found the solution here:
Android - Switch Tabs from within an Activity within a tab
In my case, I have used the solution of 'GrandPrix'.
I think you need to first know about the Tab Widget:
http://developer.android.com/resources/tutorials/views/hello-tabwidget.html
http://www.androidpeople.com/android-tabhost-tutorial-part-1/
You can set the tab using setCurrentTab method:
tab_host.setCurrentTab(2); // 2nd tab button is showing initially
same way, you can set the tab-button on the cancel button.

how to show alert inside an activity group?

I have a tab bar inside my app and to maintain it I have used activity group. On clicking these tabs I have to show a set of activities. My problem is I am not able to show an alert dialog or any other dialogs inside these activities. An error occurs saying "unable to add window". Can anyone tell how to solve this issue?
It gives above error because of the Context I was providing to alertdialog builder.
Give:
new AlertDialog.Builder(getParent()).setMessage(“Hello world”).show();
We just need to call getParent() instead of AlertDialog.Builder(this)

Categories

Resources