Append different actions in 1 framelayout through menu choices - android

I am working on an Android application for tablets. I have 1 static menu with 6 buttons and 1 framelayout in which I wish to load the content related to a menu-item. What I want to achieve is that only the content of the framelayout changes but not the entire screen.
I think there are 2 choices here, 1. multiple activities or 2.multiple fragments in 1 activity. I would like some advise or suggestions wether these are the only options I have and if so, which one you would recommend and why.
Thanks in advance.

For this kind of problem you should use Fragments. FragmentTransaction.replace is designed for this kind of interaction.

Related

What is the best way to build app architecture( activities and fragments)

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!

Two Activities in the same view

In my application, I have two activities. One for display comments, and one for add comments.
In Landscape, I want to display the two activities on the screen, the comments at left and the form at right.
Do you have an idea to do this ?
Thanks a lot!
So what you need to do is to move your Activity's logic to Fragments. Then create new layout for landscape mode that will contain both of that Fragments.
Just follow this tutorial and you will see how to do this. The Design Philosophy part fully describes what you want to do.

android - using a button action muliple time allover the app

in my app i am trying to implement the design of facebook homepage.
I have 7 different activities in my app. For all the 7 activities the buttons in the title(application bar) and footer part to be the same and same actions.
Now my question is, whether i have to create separate 7 layouts for all the 7 activities and i have to write the same button actions in each activity or it can be written once and can be used in all 7 activities ?
if it can be used by writing only once, how to do it pls suggest me a best way ?
You should probably create a Fragment that contains the buttons, an then reuse the Fragment in every Activity.
Check this out for more info about Fragments:
http://android-developers.blogspot.no/2011/02/android-30-fragments-api.html
you should create Header and Footer xml files separately
and then use "<include other layout>" Android Layout
to include your header and footer on each Screen.
let me clear if any doubt i have done this, very easy.
also you can check this SO thread

Android Layout Fragment/Activity Confusion

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.

How to use header and footer in android

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.

Categories

Resources