I am developing an app in android in which I need a header and footer through out app while switching between different activities. The header and footer text will change while switching between activities. What would be the best way to achieve this approach? Actually the header will show navigation of app.
I do not want to create them on each next activity. So that when switch between activities only internal content should switch from right to left not the header and footer
This is not possible with separate activities, sorry.
You could recreate what a TabActivity does? So you'll load your activities in your "raiActivity", and instead of having various tabs, you'll have a header and footer.
Check out ActivityGroup for this
May work with
fragments
but i don't know how to explain it to you. Google search tutorials for fragments and even frame layout maube you get what you want. This was the closest i got to answer my questions about something like that.
Related
I am building app right now. I am trying to follow all design patterns and google suggestions for building responsive apps.
Firstly, my app will contain navigation drawer.Of course my app will have several activities. So I have searched the best way to have navigation drawer on all activities, I found that the most correct way is to use some BaseActivity class which will have navigation drawer in its layout and framelaout for storing each activity representation(container for fragment). It can hold fragment, but the problem is that only one fragment.
So I have faced this problem. I am going to design following activity
So as in the picture I wanna to have image slider at the top , and some other layout parts under this slider for example grid layout, list or something other.
I think it would be better to separate image slider and other part, for example when my scree will be in landscape orientation it should be replaced but something other.
Futhermore others activites also gonna to have several independent parts for example list and anything other widget.
But as far as my activities should extend BaseActivity class, they would have only one place(container) for storing fragment.
I have tried to think about ways to solve this problem , and I have only one idea is to create several fram layouts in base activity(equal to max fragments used on child activities) and setting them visible and invisible depending on needs, but this approach pretended to be only way of hidding problem.
I don't know what is the most correct way to implement such type of application, so I need help or advices from more experienced developers to build my app correctly and bring user good experience.
I hope you can help me.
Thanks.
To start with, the container in your BaseActivity does not have to necessarily be a FrameLayout. For example it could easily be a LinearLayout with android:orientation="vertical", so that all fragments you add in it will stack one below the other.
Also each fragment can has other nested fragments in itself (although that's generally not the best practice, as usually it indicates some bad UX decisions).
Both those said, I think you just use the first point I made here. Now if you choose this one, I'd expect the question how to handle tablets and other big screens? Best way to handle them is to create a new landscape layout for your BaseActivity, where the fragments container might be different, for example a RelativeLayout, a LinearLayout with orientation="horizontal" and so on.
Good luck!
I have a design for an app that will have a row of buttons below the action bar. Each button will open a different fragment. I am aware of ViewPagers, but I do not want the swipe between fragments functionality. I know that I can disable this functionality, but at that point is it worth using a ViewPager? I know this is a pretty common design paradigm, so how do most apps handle this sort of thing?
It seems like the ViewPager will provide some nice functionality out of the box, like switching between fragments and what not. So, I am leaning towards using one, but was hoping someone could provide some feedback on this approach.
Thanks!
Keep the buttons in the layout of your main activity. Have them call a function lets say loadFragment(Button button) on click.
This function then handles switching of the fragments, and you can change the display of the navigation buttons inside this function itself to highlight the appropriate button or something equivalent.
Google Design is always worth the reading.
Check http://developer.android.com/design/patterns/swipe-views.html for details.
Personally I have used ViewPager with tab layout for swiping purpose and it makes it easy to me to synchronise the transitions ( tabs and pages) where I put a red circle to the tab corresponding to the viewed page. With this approach I got a clean separated code.
I have existed code for two activities(ActivityA and ActivityB).
Now I need to have a another activity, which will act as my first and only screen of my application. This activity will be having two tabs on its header part and I need to display each of my Activity when user press on each tab.
I have done some search on this and found TabAcivity will be suitable choice, but it is deprecated now.
I saw many posts which are suggesting Fragments. But I dont want to change my existing code. Can any one suggest me easy method to incorporate this.
you can use Android Tab Layout with Swipeable Views
here i give Link in this link step by step information given. so i think you can get batter idea from that.
Tab Layout with Swipeable Views
you can also download code from this site and also see video in given sit
I am making my first android application with the ActionBarSherlock.
The application will always have an action bar consisting of 3 tabs (first tab selected by default).
The app could be extended for use with a tablet.
I have been searching the web, and following the android development guides, however I am finding a few things confusing.
The first tab screen will be a list view with a list of items, onitemselected should send the user to a screen which features more details about that item.
When should I use a fragment? Should each tab be a fragment?
Or, should each tab call a new activity, which consists of fragments?
And, if using fragments, should I place them in different classes, or embed them within an activity??
Appreciate any help, thanks.
you should probably read these two links first.
http://android-developers.blogspot.com/2011/09/preparing-for-handsets.html
http://android-developers.blogspot.com/2011/02/android-30-fragments-api.html
If you plan to make an app that work on both phone and tablet. It is a good idea to use a fragment, and then use a shell activity to wrap that fragment.
My experience with Fragments is mostly on ViewPager, so I am not entirely sure if it applies here.
In Android, you should use Fragments as much as possible. As a general rule of thumb, imagine you are translating the UI from phones to tablets, elements that can stay together in the same configuration should be a Fragment.
There is a Fragment subclass called ListFragment, so you might want to look into that for your first tab. (ListFragment is for Fragment like ListActivity is for Activity)
There is also a tutorial I found to deal with fragments. Did not really look into it but I hope it helps.
http://android.codeandmagic.org/2011/07/android-tabs-with-fragments/
As for ActionBar / ActionBarSherlock, I have absolutely no experience withit so someone might want to add to that.
I have a tab layout, inside which I am successfully able to lead an Activity.
However, I would want such a mechanism so that I can have few buttons in the bottom, and when the user clicks them, I am able to load different Activities inside the same Tab.
This functionality may closely resemble having Tabs inside a Tab, which, I feel, isn't a good practice and will make the things quite unpredictable.
how to do something like this?
What you want to do can be achieved by using Activity Groups.........
Search for some samples........
I am providing two links, check if it helps you............
Link1
Link2