is it possible to insert one Android fragment into another? I haven't noticed any information in SDK about this.
The behaviour of nested fragments is undefined, see #hackbod's answer here
Related
I'd like to start implementing UI Tests on each of My Fragments. I just have some Math formulas to verify in each Fragment.
Let's say that from Fragment A I have to go to Fragment B and then to Fragment C(I want to test if each of Fragment's C EditText text changes if a certain button gets clicked).
I Would like to don't go throughout all of the passages to arrive to Fragment C.
I've already installed Espresso using Gradle, but what to do After? Please provide a Step by step implementation.
Thank you in Advance.
Maybe this would be helpful: https://stackoverflow.com/a/27370190/7861694
Or/If you using Espresso I recommend the second option - add a unique id for one element in your fragment layout. https://developer.android.com/reference/android/R.id.html
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'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
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.
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.