Android :: one activity in two tabs? - android

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.

Related

actionbar's upNavigation from activity to fragment

i have to jump from activity A to fragment2 in activity B(in the activityB, i use the viewpager,which contains four fragment).what i want is when i use the upNavigation of the actionbar ,i just jump to the exact second fragment.
can anyone help me?(i have searched for some related questions ,but it seems they all navigate in/between the fragments,which is not my want.)
Use this , detect the onclick
ViewPager.setCurrentItem(pageNumber);
above line will navigate you to that page

Android Actionbar tabs Navigation

I am a beginner in android. I have created Tabs using ActionBar tabs. Now I want to implement, when the user in in first tab and clicks back Button activity should close or when the user is in second tab, he clicks the backbutton the app should show the first tab, which will make it as the home tab. I tried using popupbackstack() but it always closes the activity no matter what tab i am in.
please guide me. Thanks in advance.
The easiest way would be record the tab state (i.e., which tab is showing) in the host activity, and override the onBackPressed() method to do what you want.
Some tips:
remember to save the state(override the onSavedInstanceState() and save the tab state) to make you activity works right after restore from onPause().
read about android's recommended navigation style here. What you designed is a little bit different from what android suggests.

Make activities sub-activities of one main Activity

I know the title looks weird but this is what I want :
I have two tabs, and under one tab I have an activity that has a file list. When you click on a file it normally shows a panel next to it (which is another activity). But now, since I have tabs, when I click on a file it jumps to a full screen activity with the file description and the tabs are gone. I would like to make this second activity a sub-activity of the main where we can select a file so that the tabs stay still.
Any ideas ?
Thanks,
Nic.
Tab host with fragments should solve the issue.
You may like to read this - http://android.codeandmagic.org/2011/07/android-tabs-with-fragments/

TabHost keeps adding the dynamic tabs when app restarts after Back Button pressed

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();

android activity only happens once but i need it to repeat

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.

Categories

Resources