How to add data or activity to tab in android - android

See My previous question (Linked here) . I am with answer but now i want to add data to tabs by intent activity or any other procedure how to add widgets or any other resources because when i intent any other class its show in all the other tabs also. How to get different activity in different tabs ?

You have to put your stuff in tab host and make linear layout or Relative Layout for your each tabs (below frame layout).

Related

How to implement horizontal view android studio

im trying to implement an android aplication when your activity, cointains 3 or more 'main windows' like in the image -> 'A'. 'B'.'C'. so how is posible make when you slide you touch screen change from A, to B, for example, i was thinkin in a horizontal view, and inside of each item use a relative layout, but im not sure, its my first time with this kind of problem, thanks.
Try using android ViewPager. Each ImageView would be inside a Fragment that would reside inside your Activity. Check out this example
Use Tabbed Activity template when you want to make this type of Activity. ViewPager, Adapter and tab layout will be automatically implemented for you. Just make small changes in your Adapter according to your needs and use one Fragment for one tab and you can create as many tabs as you want in an Activity.
If you want i will post an example of an Adapter as i just implemented an Activity with 3 tabs.
To get your basics strong on ViewPager, tab layout and Fragment sections adapter read out this link.

Android TabHost with ActivityGroup effect without TabHost

I want to create a tab menu similar to TabHost but I would like to use some other elements, not only buttons in that menu, and also be able to bind some other actions than start new activity to buttons.
Basically I need an activity with a layout that I will be able to show in part of every other activity just like TabHost with ActivityGroup. Is it possible at all? Ask me if you didn't understand my idea.
how about using a horizontal scrollview that has a linear layout (with horizontal orientation) , which has all the views that you've mentioned?
beneath it , put a fragment container which can change its content.
if you are unfamiliar with fragments , check the api-demos , or , for "old" versions of android (gingerbread and below) , check the support library demos (v4) .

add dynamic view to android tabhost

How can I add a dynamic view in a TabHost.
I have two tabs i.e. TabA and TabB. In TabA, I have 2 buttons and I want to set the layout (I have 2 different XML layout's) of TabB, depending upon the button pressed in TabA.
Can anyone help me.
Thank you!
That depends on the implementation of your TabHost. Have you used Activities or Views as Tabs?
Generally in your TabActivity you could use getTabHost().getTabWidget().getChildAt(index) or another method to get the view of a Tab.
If you use Activities as the children, you could also start a new Intent with your ActivityGroup and set a new view within the onCreate() method.
If you have problems finding examples for ActivityGroups with TabHosts, I can provide you a code sample showing you how to do it and also how to change the view within another tab by clicking a button.

TabHost View Problem

I have a problem in layout.
I am using TabHost in my application. In that there are 4 Tabs.
In one of the Tab i have used 3 Buttons.
What I wanted to do is :
When i click on one of the Button, the TabHost and the Button should remain as it is and it should display me the contents (Set according to onClickListener) in that activity itself.
Take a look at the answer of this question: Changing the view within the Android Tab Widget
Ok, but the thing i don't understand: where should it show you the buttonClick result? If you want to set the activity in tab not to reload each time, you should use .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) in the corresponding tabspec declaration

TabWidget problem with new activities

I use Tab Widget like in documentation example TabWidget
I have two tabs, and in every tab when I press some button I need to load another different activity. My question is how to achive that I have that two tab on another activities like headers ?
I could create that tabs in new activities but it wouldn't remember choosen activity for another tab. How to solve this ?
This is not possible out of the box. The normal TabHost doesn't provide any facility to change the content of a tab after it is created. If you can use views as your tab content, you can, however, flip between the views within a tab so that to get the effect you are after.
If you absolutely must use a new Activity, then you will have to implement your own TabHost which allows swapping tab content after it is created.

Categories

Resources