I have one swipe tab with 3 fragments. In the first fragment I want to put two fragment, one fragment for information and one for login operation. I'll ask you if it's possible doing it and with how API it's possible this. I've searched in the web information but I don't understand so much. If it's possible, I need an example.
Thank you
Related
I am very new to Android specifically to Fragments. I am making a Tab layout using ViewPager and Fragments.
Now my problem is that, I want to add fragment to viewpager dynamically meaning The number of tabs will be according to users input. If user selects 10 then 10 Fragments should be created at Runtime/Dynamically. I don't want to pre-define the fragments.
I have looked at lot off solution but none of them was any helpful.
I will really appreciate some kind of guidance.
Thanks
I would like to create a good base for my app and have it working efficiently. I am a bit lost still with understanding the relationships between fragments and activities (in the basic form I get it, but in cases like the one I need to deal with now I am not sure what to do).
Currently I have 3 fragments in a View Pager, very simple stuff. one of them is for gallery, one of them is for profile and one of them is for forum (imagine the question board here on SO).
Now, inside the forum fragment I have a FAB that should open a new page for asking a new question.
What I am wondering about is, should the new question page be a fragment or an activity? Also, when a question is clicked I would like its thread to open with all the comments. That should be a fragment as well correct?
If fragment, where do I load it into? The View Pager? If so how? Can the view pager host a fragment temporarily? Because the fragment should only be visible when the button has been clicked. Should I place the fragments inside of the forum fragment so it'll serve as it's parent fragment?
I can make it as an activity, but by what I read and know about fragments, it makes sense that it should be a fragment because it is part of the same activity, but when that is that case I am not sure how to do it.
I would actually not use a ViewPager in your case. I use ViewPagers for a series of related screens that deal with a very specific task. For example - a wizard that details instructions where each Fragment might represent a step and it's useful for the user to be able to slide back and forth between instructions.
Given your requirements I would still host everything under one Activity and the individual pages as Fragments inside that activity. Then maybe use something like a bottom nav bar to navigate between the profile, gallery and forum. The screen that is launched by the FAB and another one for viewing the thread of a forum post should be also be separate Fragments as well.
This might be a good opportunity for you to try out the navigation framework under Jetpack. It makes these kinds of things a lot easier to visualize.
See here Android Navigation Framework
I am A beginner at android. I have created an app which loads news from JSON to recycler view. I want to open an activity when the user swipes from left to right. I tried different methods but it doesn't work for me. Please help.
You have to create an activity first and put a view pager in it and switch between fragments : ( its better to use fragments at this kind of situations, u can swipe between ur fragments by using android view pager )
Here is a great link that gonna help you :
https://medium.com/#kyroschow/how-to-use-viewpager-for-navigating-between-fragments-with-tablayout-a28b4cf92c42
Have a good day
The better option is to use one Activity & other Fragments. And then use Viewpager for swipe between fragments. Follow below link:
https://developer.android.com/training/animation/screen-slide
I am trying to figure out how I can implement the following scene. I have an activity where the user needs to enter some information through edit texts, like names start times etc.. The user has the opportunity to add more than one information block. By hitting the add button as you can see in the drawing below. I thought about implementing it wit a ViewPager and a fragment. As I need only the same fragments multiple times I don't know how to dynamically add fragments to the Pager and how to remove them dynamically. If anybody knows a solution or an other approach that would be great. Thanks in advance.
I have made a swipe tabs using fragments. But is possible to use activities instead of fragments? For example. I have 3 swipetabs, "View","Add","Delete" and 3 seperate activities for each on of these functions. Is there a way that if a swap from "View" to "Add", it takes me to the "Add" activity, an so on.
As i don't have enough reputation i cannot comment on this so am answering. Instead of using activity try to use fragment as google suggests you can do everything in fragments same as you can do in activity infact you can do more thing in fragments so i recommend you to use fragments so please take a look at communication between two fragments https://developer.android.com/training/basics/fragments/communicating.html