Display part on another Activity (or Fragment?) Android - android

I have to deal with two ActionBar displayed at the same time on the screen. There's an onClickListener on the second one which allows the second activity to be shown on the entire screen after a click, with an animation.
I have no idea how to do that. Two activies, fragments? ViewPager? ... Absolutely no idea. Could you please help me? Thank you.
EDIT : here is a picture of what I wanna achieve http://romainpellerin.eu/so_android.png
You have to see it in order to clearly understand my problem.

Definitely Fragments.
When you bring in the second fragment specify animations in the fragment transaction before you commit it.
There are tons of tutorials online. Here some more help.
Android Fragments and animation
SDK
http://developer.android.com/guide/components/fragments.html
how to make fragments backwards compatible
http://developer.android.com/training/basics/fragments/support-lib.html

Related

How can I show two activities at a time in android

I have 2 activities, In first activity I have a button and I want when user clicks or move up that button the second activity come from bottom and stop when it goes to the half of the screen. I don't understand how can I achieve this. I also searched google but they show some type of dialog boxes :(.
This is what I want. When app start 1st activity is shown on the screen but when user click ^ this button both 2 activities show 50% on the screen.
Can anybody tell me how can I achieve this. Is it possible???
You would achieve this using Fragments.
I would suggest you start with the offical documentation - https://developer.android.com/training/basics/fragments/index.html
In order to create the interface above you could use fragments instead of activity.
In your case you need to have an activity with two fragments (you can use coordinatorlayout).
If you don't have enough knowledge about fragments I recommend to read those articles:
Codepath fragments guide
Vogella fragments guide
Convert Activity to Fragment and use <FrameLayout> on page to display/remove fragments from page.
Fragments are reusable components Refer to convert Activity to Fragment
This might help you understand how to work with Fragments link
You should read about fragments. They can be used for the UI you described. You can make it so that a second fragment is GONE, and when the user presses a button, it becomes visible. You should probably use a relative layout for the two fragments.

should I use fragment or viewpager for my app

Demo1
Demo2
when users click the button to answer the questions for the TextView on the top, the TextView will change the questions depends on the user's answer.
(I think this part won't be hard for me)
But what should I do after user click the button, the buttons will change as well, please see the demo picture.
are there any skills I should study first? like framelayout?
Thank you for your answers.
It really depends on specific needs, but generally speaking, google guidelines are toward the use of fragments.
I'm developing Android apps since just few months and I'm using the single activity/multiple fragments approach. You have to learn how to use fragments, e.g. their lifecycle compared to the attached activity or how to handle events among fragments (EventBus can help you for such task).
You can find more discussions about this approach here
Cheers.
you can create a N fragement with your nuber Button and you set your buttons in this fragement (Demo 1)
but in click a one button you can replace a Specific Fragment (Demo 2) in your framelayout be placed in your Activity

Android Studio multiple fragments

I'm designing a music player app and this is my second time working with android studio and fragments in general. I've watched a lot of tutorial videos on this but I'm having trouble getting multiple fragments to show. Maybe using fragments isn't the way of going about this. But basically what I have right now is a fixed menu at the top and 5 fragments just below it (on top of each other).
What I was hoping to do was by clicking each button one fragment would load so you would have one activity but 5 fragments that load when buttons are pressed. But the issue i'm having right now is instead of stopping one fragment and loading another one, they're being loaded on top of each other. Is there a way to go about doing this?
Below is an image of the design I had in mind. The blue box is where the five fragments are and right now they're overlapping. Any help would be appreciated :)
EDIT: Turns out the answer was I needed to define one layout for all of the fragments. Thanks everyone.
Please post code. But here's what I can make out so far from your problem,
I assume you are just using FragmentManager.beginTransaction.add() again and again.
If it is the case please change your code to
FragmentManager.beginTransaction().replace(
containerViewID,
new FragmentYouWantToReplace
);
What this does is removes previous fragment and adds this new fragment.
So you can have your default fragment using add() during activity load, but for each button click you use replace().
When you call a new fragment you should replace always the same layout, the one you want to show the information, like this:
frag_results frag_results = new frag_results();
FragmentManager manager = getSupportFragmentManager();
manager.beginTransaction().replace(R.id.framelayout_secundary, frag_results, frag_results.getTag()).commit();

Swiping between XML layouts in Android

I'm right now working on a launcher app and I have three Activities. User is on 2nd Activity by default and when user swipes left it should take him to 3rd Activity and when user swipes right it should take user to 1st Activity. Just like Swipable Tabs but the Tabs should not appear. Is it possible? Best example is of Home Screen, I want it exactly as Home Screen. I've tried a lot! But I'm not getting what ACTUALLY I want, any help would be gladly appreciated, thanks!
I hope I can get you well.
First personally I don't suggest achieving this goal by using multiple activity. A better way might be one activity containing multiple fragment.
Then if you do so, several tools can make help, ViewPager for example.
If you want to add some view page indicator, as what the homescreen looks like, then ViewPagerIndicator might be a good choice.
Hope it helps.

Navigating between activities in android

Can someone tell me how do the following works:
in an application there are something like header with titles. So you can scroll the screen down to see all its information and then throw it to the left and see another screen, like with messages.
This functionality of vk.com
Sounds like what you are after is a ListFragment and a Fragment used with a ViewPager.
The ViewPager gives you the funcionality of swiping left and right, and the Fragment class is a really good way of implementing things, since they are reusable and can be placed in different activities.
have you tried to use ViewPager? You can see it's functionality in Play store application.
You need use class ViewPager. My advice - use fragment.

Categories

Resources