Start activity in tab using fragment - android

I have tab activities (tab1, tab2).
When button1 is pressed in tab1 activity it covers up the whole screen. How to start another activity in the same tab?
Is it possible to start ContactsContract.Contacts.CONTENT_URI in tab1?

Check FragmentTabs.java example in the documentation.

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 :: one activity in two tabs?

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.

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 tab activity

hi all
i have a tab activity in which there four tabs
now this activity can be started by three other activities
based on the activity that started the current tab has to be set in the tab activity
i tried using extras specifying which should be the current tab in the intent that started the tabactivity
but it dont seem to realize the extras at all
You can do it using
myTabHost.setCurrentTab(2);
method. So just pass the tab id you want to display first with intent. Use it in your myTabActivity.java to display the tab you want.

keep activity going in background when switched to another activity?

I have my main activity going and a button going to a different activity. When I go to the other activity my main activity stops. How would I keep the main activity going?
Thanks in advance.
How would I keep the main activity going?
You wouldn't.
Depending on what it is that you are doing, you might consider moving it to a Service.
Yes, you can keep your main Activity running. My way is use a "CHEAT".
Example your main Activity is A, in A we have button btnA. Click this btnA will open activity B.
You create a tab bar with 2 tab contains A and B. After initialize tab bar, call
tabHost.getTabWidget.setVisibility(View.GONE);
to hide this tab. So you only see main Activity visible.
When btnA is clicked, only need to switch tabHost to B
tabHost.setCurrentTab(1);//1 is index of Activity B
This question & answer is similar with your question. You can refer to it.
Activities and sub activities

Categories

Resources