How to use multiple Fragment in single activity in different times - android

I am making an app in which the header and footer would be same through out the app. i can start another activity with the same pattern of design in header and footer but as the other activity starts there comes a delay and we can easily notice that a new activity has pop up.
So what I want :
I want that if user click on any button from the footer the content in the middle between header and footer should be change and user should not see any jump which is made when I move to other activity.
So for this I know that I can use fragments. But for some reasons I can not use fragment activity. All I want to move fragment in the center only. So How can i do that . and How can I initialize other things which are in new fragment let say the upcoming fragment could have button so in this way , I wanted to know would it make my main activity heavy which is calling all these fragment
So please guide me through the demo code .
Note: please do not refer me to a fragment link just past some code to give me some idea.

Will be easiest to have the activity implement the header and footer and the variable content as fragments.
Please refer to this post. It has everything you need
Fixed header and footer in android app

Related

What is the best practice to use multiple layouts in one Activity or Fragment?

I have a fragment for user registration in that fragment's XML, I have a fixed header and a footer. The header consists of steps for showing the current progress or number of the visible fragment. The footer consist of two buttons for next and back, when I click on next button I want to show the second layout of the registration form and change the colour of the header step so that user can check that he has completed one step and is on the second step, and back button appears because I'm on the second layout. When the user finishes entering all the fields I want to check for validations like email patters is correct, password pattern is correct etc, then send all that form data to the server for user registration. My Question is what is the best practice to do such thing, should I use one fragment and in that fragment I include all the layouts and play with the visibility of the layouts, like if i press the next button the second layout gets visible and first gets gone but the data filled by the user must not get lost because i want that data to get validated and send to server. Or i should make a MainActivity in that main activity i call all the three fragments on button click like if I press the next button the second fragment replaces the first. But again the question is if I go with the activity containing multiple fragments method what will happen to the data of the fragments when user will click on next and back button?
I know it's a long summary of my question but I want to know what's the best practice to do in such cases.
Any help would be appreciated.
You should use fragments within a viewpager. This will also additionally give you the dots at the bottom visualizing what page and how many pages in total.
read more about viewpager

Using a single button going through multiple fragments

I am developing an app in which I have an on boarding. I have a "next" button at the bottom of the layout which will load the next fragment. The problem is how to do this when I will have to go through 8 fragments. The order in which the fragments will be displayed, never changes. Should I use a counter or should I ask which fragment is being displayed and then go to the next? Any help is welcomed, thanks.

Reusing the common layout in android application

I am trying to make an application that has the following design.
Login->Dashboard
Dashboard has a #navigationdrawer having a listview ,of which every item opens a fragment.
Dashboard has a view pager of two pages.
Page 1 : listview
Page2: search bar.
Till now this is in place.
Problem statement :
The #page2 is constant it has to appear on every fragment ,but #page1 changes for every fragment . Can someone help me achieve this.
I am not getting how to do it.
I think you should use search menu item in Dashboard's ActionBar instead of fragment and display it using viewpager. Check following link to make search interface.
http://developer.android.com/guide/topics/search/search-dialog.html

Keep footer for multiple activities

I'm creating an app which requires the footer to remain constant among various activities. That is, when animating to another activity, the footer doesn't animate with it - it stays there. Here is an example of what I mean: http://www.youtube.com/watch?v=EwXjdTvVXHQ&feature=related
I know it's an awesome app, but please don't forget my question ;)
Use Fragments to switch out your content, then you can keep one activity with the same footer. Fragments are backported all the way to Donut.
Use only one activity with footer and body in your app, switches and animates body only just like switches in activities.
Create a dummy class that extends an Activity and add footer to it.using xml (or the sameway you would do for other activity).
And extend this class in your app wherever you want footer.

android-adding tabs in view flipper

I am developing an android application in which I have creted a TabActivity. For each tab I am using a separate activity and a separate layout file. Actually this activity is a details screen which shows customer information. The user can click on an item in a listview activity in order to see customer's detailed info in the tab acticity. There he can use navigation buttons to navigate through the customers In a few words, if the listview displays 10 records and the user clicks on the first item the customer details.tabactivity opens and displays detailed info. Using the navigation butons the user can see the next or previous record.
Now, I would like to use a viewflipper in the details screen in order to use animations while navigating through the records and in the end. to use fling gestures instead of buttons. Nevertheless I haven't found a proper example of how to add a tabhost/tabactivity in the flipper. I also thought to create the tabs using one layout in order to add it to the viewflipper but then I have no way to create the tabs inside the activity that hosts the viewfliper.
Any help would be apreciated. Thank you in advance.
ps. I will create a basic app of what I am talking and upload if that would be helpful
The ViewPager may be more appropriate for what you are trying to do.

Categories

Resources