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.
Related
I am stuck with a problem where I have designed a tab layout that I have used as a library in the current project which has a Recycler View. I want to show the tab layout on top and the recycler view under the tab layout.
For reference in Whatsapp, there is tab layout under which there is a recycler view that shows all the messages.
Problem is that I am confused about how to combine both activities together so the user can use the tab layout.
If anyone knows any solution please help!!
Use single-activity pattern. This pattern means that you need to use Fragments in a single activity (MainActivity, etc). Additional tip, you can use ViewPager2 with TabLayout for your Fragments.
Activities can't be composed into one, cause it designed so.
I am facing a situation as of few days now. I intend to create an activity where there is a TabLayout and a ViewPager.
The tabs in TabLayout corresponds with the fragments/slides in the ViewPager.
Now as of now, each fragment contains the same format,i.e., two TextViews, one under the other, populated with the strings softcoded in string.xml
But this resulted in the creation of too much xml files for the fragments used inside ViewPager.
So I was thinking if it's possible to use only one fragment inside the ViewPager and then programmatically set the strings for those two TextViews in the fragment, that changes each time w.r.t. click on another tab or sliding on the ViewPager area.
This will lessen the no. of fragments to only one, in turn cutting the time to create it and increase the overall performance of the app in which it will be present.
So any insightful help, suggestion, or walkthrough on how to implement this concept - any help on how to do this will be highly appreciated.
You can certainly do that. If you're using FragmentStatePagerAdapter, just initiate the same fragment with different arguments supplied according to it's position and then in fragment check for those arguments and make changes accordingly.
I am making an app in which the header and footer would be same through out the app. i can start another activity with the same pattern of design in header and footer but as the other activity starts there comes a delay and we can easily notice that a new activity has pop up.
So what I want :
I want that if user click on any button from the footer the content in the middle between header and footer should be change and user should not see any jump which is made when I move to other activity.
So for this I know that I can use fragments. But for some reasons I can not use fragment activity. All I want to move fragment in the center only. So How can i do that . and How can I initialize other things which are in new fragment let say the upcoming fragment could have button so in this way , I wanted to know would it make my main activity heavy which is calling all these fragment
So please guide me through the demo code .
Note: please do not refer me to a fragment link just past some code to give me some idea.
Will be easiest to have the activity implement the header and footer and the variable content as fragments.
Please refer to this post. It has everything you need
Fixed header and footer in android app
I use a View Pager in my app to get animations between fragments, but I've got a problem because I use a button to pass fragments, I have disabled swipe option, and when a fragment pass to other, it is really quickly and you can not see anything. I want to pass more slowly so, Can you help me please?
I use this method to pass fragments:
myViewPager.setCurrentItem(int fragment_position);
If you need more information just say it.
I am developing an android application in which I have creted a TabActivity. For each tab I am using a separate activity and a separate layout file. Actually this activity is a details screen which shows customer information. The user can click on an item in a listview activity in order to see customer's detailed info in the tab acticity. There he can use navigation buttons to navigate through the customers In a few words, if the listview displays 10 records and the user clicks on the first item the customer details.tabactivity opens and displays detailed info. Using the navigation butons the user can see the next or previous record.
Now, I would like to use a viewflipper in the details screen in order to use animations while navigating through the records and in the end. to use fling gestures instead of buttons. Nevertheless I haven't found a proper example of how to add a tabhost/tabactivity in the flipper. I also thought to create the tabs using one layout in order to add it to the viewflipper but then I have no way to create the tabs inside the activity that hosts the viewfliper.
Any help would be apreciated. Thank you in advance.
ps. I will create a basic app of what I am talking and upload if that would be helpful
The ViewPager may be more appropriate for what you are trying to do.