In my app I have TabActivity , and 3 Tabs in it. Every tab has some buttons, that changes current Tabs view. I mean when I'm clicking on the button, it changes the Activity in the current Tab, but when I'm going to second Tab and returning to first one, Tab is recreating. I need to keep the Tab unchanged. How to do this?
Also I didn't use fragments because it needs min API level 11
Thanks in advance
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.
I have an Android app whose main activity is a tabhost.
How do I save the state of each tab? Right now, if I start at tab A, open a new Fragment C in the tab, go to tab B, then go back to tab A, I only see the original Tab A.
Tab A --> Fragment C
Tab B
How do I make it so I can see the backstack tab?
In general, if I modify the state of a tab, I want to be able to navigate away from it, come back, and see the modified state.
I'm currently detaching and attaching fragments when I switch tabs. Is this the wrong way to go about it? Is the issue something else?
Thanks!
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 am creating an app for Android 3.0+ that uses the action bar with tabs for navigation. I have 2 tabs that each load a ListFragment:
Tab 1 Tab2
A B
C D
Where A & C are list items in Tab 1 and B & D are list items in Tab 2.
Currently if you select Tab2 and then item B a new ListFragment is loaded on top of the current list fragment in Tab2. Pressing back takes you back to the original Tab2 contents. However if you don't press back and instead select Tab1 you see Tab1's contents on top of the new content you loaded in Tab 2. So I am guessing there is a better way of doing this. I wanted to use multiple fragments in each Tab to reduce the code complexity in each tab (for instance the onListItemSelected handling). Is there another way to do that without using multiple fragments? I am also trying to just save state but I am not sure how to tell the difference from when the user clicks back (then I would want to restore state) and the user has selected tab 1 and then selects tab 2 again (i would want to restore state).
Thanks
I am having similar struggles with the complexity of fragments and tabs on the Action bar. It seems to me that android for tablets is still very much in its infancy and there are various issues (like yours and the issues I'm having) that will be addressed in the coming months. For now, I think you just have to handle some of those complexities yourself instead of relying on the Android framework.
To answer your first question more directly, I think you need to step back and think out the functionality before diving into the code. I can give you a potential solution (keep track of your fragments manually in the activity and simply add and remove fragment as necessary via the ActionBar.TabListener interface.
Also, if you want the user to be switching from one fragment to another like you are suggesting, perhaps the back functionality shouldn't be used. What happens if the user clicks on the tabs 10 times in a row. Do you want the back button to take the user back through all of those events? I think the back button should only be used when the navigation system is very sequential and "back" is an easy concept. Check out all the Google apps that use tabs to see what I'm talking about.