I have a Tab bar application with two tabs named "Tab1" and "Tab2".
Whenever I launch the application ,the Tab Bar runs and the "Tab1" in the Tab Bar get selected and it runs an Activity, because I have used setCurrentTab(0) method.
So how can I run the Second Tab named "Tab2" simultaneously along with the "Tab1" without clicking. Here I cannot use setCurrentTab(1),because I have already used setCurrentTab(0).
Any suggestions as to how I can do this?
first navigate to the second tab then come to the first tab.
setCurrentTab(1);
setCurrentTab(0);
so the second tab will be onPause state do whatever you want to do on second tab.
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 have one activity, with five tabs. When I launch the application by default first tab (with 0 index) is selected.
I want it should work like when I launch the application, none from the five tabs should be selected. when I click on particular tab then it should show UI according to the selected tab.
Make the initialization routine select one of the tabs.
Hey can we hide/show tab layout on button click which will be placed below the tab widget it self.
Eg :
When i try to hide - setVisible(View.GONE) the tabwidget whole screens goes black.
The most straightforward way to me would just use the android menu as the way to choose between different tabs instead of a real tab view. When the user clicks on a menu button, you load another activity and the menu gets hidden again.
The tabhost is meant to stay there throughout the entire app lifecycle. Using it like this would be wrong. A way to achieve this using the tab would be to set it completely invisible and then load the activity that normally is in the tab on the whole screen.
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 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.