android - using a button action muliple time allover the app - android

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

Related

Gmail like registration layout in Android

I often put user registration on one xml file with scroll view.
I have learned when a user sees too many fields they opt out of the app so I am planning to upgrade the layout to look like the one for gmail when you sign up on android app. It appears to be using tabbed view but not tabs available and user navigates to the next view by clicking next (refer to attached images).
First page
second page
MY QUESTION
My question is how do I create this views, do I need many xml layout files or put all stuff on one file and use visibility as in once it is filled and user presses next hide the inputs and reveal the next inputs. Note: Gmail appears to be scrolling to another page the way it would appear when using tabs.
You can use one activity to host multiple fragments. The new Android Studio update has Navigation Editor which you can use to achieve similar results.
it is totally up to you how you want to design this but the best thing is you use Fragment and viewpager instead of using two separate layouts.
See Here how to use fragment with viewpager
There are many ways to do this, If you have less content then play with visibility otherwise ViewFipper ( https://abhiandroid.com/ui/viewflipper ) Or can use Fragments

How to implement Tabs UI in android

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

Append different actions in 1 framelayout through menu choices

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.

managing single dashboard menu in multiple activities

in my app I've launcher activity displaying summaries of different stuff. There's one SlidingDrawer set up in each activity having a dashboard with 9 menus as content. When user clicks on drawer's handle, content scrolls up to display that dashboard. These menu launch 9 activities from dashboard and there are no of activities that will be having same SlidingDrawer with dashboard.
Now the thing which is disturbing me is, I'm forced to put same code blocks in each activity that controls behaviour of dashboard. Dashboard itself is inflated from single layout. So design is not issue. But I've to attach event handlers to each button and start new activities from there. Problem is whenever I make changes I need to replicate those changes in all activities.
How can I avoid such redundant code and use a single class or something that let me define launching of those 9 activities?
Sorry for title and description. It's really hard for me to put it in words. If you find title or description not suitable then tell me or edit where appropriate.
Thanks.
This might be a perfect situation for an Android Fragment
Have two fragments for each activity, one for the sliding drawer and one for everything else.
Android fragments seem complex at first, but trust me, learning them will make your life easier.

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