I'm considering modifing my app using fragments with a viewpager, instead of activities.
So, as I understand the situation, I should be able to modify my app, that it just contains one main-activity which contains viewpager and to this viewpager I can and and remove Fragments as I like it, is that correct?
If I am correct has someone maybe a link with a short example implementation (main-class + methods for adding and removing fragments)....
If I am not correct can someone give me a hint what the cleanest implementation for such a problem would be.
Already thanks for your time and support.
Check out the example on the ViewPager documentation it shows the usage with Fragments:
https://developer.android.com/reference/android/support/v4/view/ViewPager.html
Related
Perhaps somebody can help me understand this question about the subject.
I already made my navigation view, but now I want the same navigation view in my other 2 activities.
What I don't understand is how should I properly implement my layouts for the rest of the activities, because trying I ended up practically cloning the first layout.
My doubt is exclusively on the building/writing of the layouts for the other activities.
Would have comented there, but my reputation does not allow me.
Use fragments, make your navigation layout a fragment and place that fragment wherever you need that layout or you can also create a parent activity class in which you implement your navigation layout and extend that activity in rest of your activities.
This is the EASIEST and CLEARER implementation for what I wanted to achieve, code might use some optimization, but does what I was looking for after reading several posts in the last three days.
I am planning to start an app from the scratch and I need to know wheather a COMMON Navigation drawer is applied through out multiple activities without using a fragment inside the activity.
I tried many examples but none worked for me. Any help should be greatly appreciated.
Yes it is possible create one base activity and implement the drawer in base activity like here. and extends that base activity
As far as I know it is not possible. I've personnaly used a single activity hosting a navigation drawer instantiating differents fragments to swipe between them.
Here if you wanna do it: http://developer.android.com/training/implementing-navigation/nav-drawer.html
The best you could have to get kind of the same result with activities is playing with transitions params in each of their class. It is kinda heavy. Use fragments for this purpose.
The following topic could bring you some work elements if you still wanna do it: Android how to add swipe Gesture on LinearLayout without onDown true
But keep in mind that it won't be as smooth as the navigation drawer with fragments.
As far it's not possible without using fragment. and why you don't want use fragment.?
Fragment is a best thing to achieve this.
Here i am attached some links.
I hope that links are use full for you.
https://www.learn2crack.com/2014/05/android-working-with-fragments.html
http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/
I have two different Activities, and I want to show them both at the same time in another Activity. Is there any way to do that?
Thanks in advance!
its not possible , You have to use Fragments to do so...
convert those two Activities to Fragments and create a Activity and place those Fragments in Activity.
Ref :
http://developer.android.com/reference/android/app/Fragment.html
http://developer.android.com/guide/components/fragments.html
Yes, it is possible with ActivityView in android. There is no proper documentation that is available on the internet. but if you can check the android source code you can able to find the code related to ActivityView. Android is using the ActivityView for its car launcher applications.
check out below links:
google implementation of ActivityView.java
you can find the ActivityView.java usage examples
here
and here
Yes there is a way ! You cannot display 2 activity inside one, you have to use fragments !
A fragment is an independent component which can be used by an activity. A fragment encapsulates functionality so that it is easier to reuse within activities and layouts.
A fragment runs in the context of an activity, but has its own life cycle and typically its own user interface. It is also possible to define fragments without an user interface, i.e., headless fragments.
Fragments can be dynamically or statically added to an activity.
You'll find the answers of all of your questions about fragments on this link
Hope it's been helpfull =)
Fragments and FragmentActivity comes into play here. Make your two activities separately as two different fragments, And attach these two fragments into a FragmentActivity. So that in a single screen you can view two activites(Here its a fragment).
You can also try using ViewPager concept it may suits to your scenario.
Download the sample here,
http://developer.android.com/training/animation/screen-slide.html
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
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.