so my app has two tabs
tab 1 is a login page then
tab 2 is a user details
the user needs to loginfrom tab 1 then only details would load from tab 2 so if the user didn't login and goes to tab 2, an alertdialog would show the problem is, after going back to tab 1 and if the user does not login again prior to tab 2, the alertdialog would not show again. I'm not sure if I should use onRestart or onPause or something..
SOLVED!
the easiest way to do is to set the flag in the tabhost .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
thanks for the help guys :D
Change Your Application Flow.
make one tab represents a set of activity.
make use of activity group.
Related
I am working on a Tab Activity. I have one activity as a tab content
of one tab. I need to use the same in another tab also.so I have set
the a single activity as a two tab content. But when I am running my
code . If I am selecting the TAB1 after that I am selecting TAB2.
Again I coming back to TAB1. whatever event like entering name in
edittext is reflecting in TAB2 not in TAB1.I don't know understand why
its happening.
Any Idea? Thanks in Advance.
You haven't mentioned that what you are doing onTabChanged ie. whether you are starting that activity again or not.
I think everytime when you are selecting a tab you are staring an Activity.
startActivity(intent);
So, whatever change you have made in that activity under Tab2, won't reflect on that activity under Tab1 as you are starting that activity again.
If you are starting that activity everytime ontabchanged, then you have to save the changes what you have made under any tab.
As you haven't mentioned clearly what you are doing, so if you are doing something else, let me know.
I'm creating the 3 tabs dynamically based on example here http://developer.android.com/resources/tutorials/views/hello-tabwidget.html
the application works well except one issue.
when I launch app and then click the Back Button then the app closes.
I launched the app by clicking on the application icon.
now I can see 6 tabs. each time I repeat this process, it keeps on adding 3 tabs.
when ever I use Menu button instead of back Button then it doesn't add 3 tabs.
anything going wrong here, how can I fix it?
thanks
Are you creating the tabs at onResume() or onStart()? Try to create them at onCreate()
or delete the tabs by onPause with something like:
LinearLayout tabbar = (LinearLayout) findViewById(R.id.tabbar);
tabbar.removeAllViews();
I want to refresh the tab with its latest content, even if the user is coming back to the activity from a previous home button click.
You should override onSaveInstanceState() as explained in this question.
Just make sure you update the tab inside of Activity.onResume().
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.
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.