Create a multi-step form based on user input - android

I need to create multiple "forms" (e.g. login, signup) and you should be able to fill in one information at a time.
After the user entered his first name he should swipe (like in ViewPager) and the next input should appear dependent on the previous (if he wants the newsletter, the next step should be entering the mail).
Some of the inputs are very complex like ordering items in a list and I thought it would be a good idea to use Fragments and the ViewPager but it is not.
The ViewPager doesn't handle the dependency on the previous input very well and it is not really possible to add custom animations.
I didn't find a library that fits my needs... Do you have an idea what I can do?

Will this library fit your needs:
https://github.com/romannurik/Android-WizardPager

Related

Android - How to have multiple pages/section in a fragment? (No viewPager)

For better Understanding check this sample design
What I want to achieve is a sign up mechanism. Where when a user done filling page 1 and click next then
The next button stays at the fixed location
The indicator do an animation and change
The two field ("Full Name" and "Select your gender") get swapped out by the fields of Page 2.
Those fields in both pages will be in same Fragment, viewModel and repository. This is a simplified version of what I want to achieve.
I am a beginner in Android & already watched tutorials of viewPager2 but I'm pretty sure it won't help here. One thing I can do is, to use "visibility hide & show" but I don't think it would be the best practice. Hiding and showing will also not help in manually swapping the pages.
So, how to implement multiple pages/section in a single fragment?

Gmail like registration layout in Android

I often put user registration on one xml file with scroll view.
I have learned when a user sees too many fields they opt out of the app so I am planning to upgrade the layout to look like the one for gmail when you sign up on android app. It appears to be using tabbed view but not tabs available and user navigates to the next view by clicking next (refer to attached images).
First page
second page
MY QUESTION
My question is how do I create this views, do I need many xml layout files or put all stuff on one file and use visibility as in once it is filled and user presses next hide the inputs and reveal the next inputs. Note: Gmail appears to be scrolling to another page the way it would appear when using tabs.
You can use one activity to host multiple fragments. The new Android Studio update has Navigation Editor which you can use to achieve similar results.
it is totally up to you how you want to design this but the best thing is you use Fragment and viewpager instead of using two separate layouts.
See Here how to use fragment with viewpager
There are many ways to do this, If you have less content then play with visibility otherwise ViewFipper ( https://abhiandroid.com/ui/viewflipper ) Or can use Fragments

Android Fragments or Layouts - advice needed

I am developing an application which should display a number of tiles on the first page. Tiles are generated dynamically from json, each should allocate itself according to size specified in json and should take as much screen as required. Each tile represents short summary of information. The requirement is that when tile is pressed user is redirected to another page which provides more detailed info (like a form) which takes the whole page. User then should be able to go back to previous page and choose another tile if needed or go back to the first one. I don't know in advance how many tiles there will be and what are their components, so everything is dynamic. There is also a possibility that small tiles(with different info) can be required to be drawn on detailed view.
At the moment I am on the stage where all small tiles are displayed on the first page and I need to find the best way to display detailed view and allow user to navigate easily and quickly. Each tile extends RelativeLayout because of absolute positioning of components inside. I am considering switching tiles from Layout to Fragments because they seem to be providing flexibility required and many articles and tutorials I search refer to them. In this case when user presses the tile fragment, all existing tiles would be replaced with required detail fragment. Pressing back button would replace detail fragment with previous smaller ones on the screen (would it be display all of them or only one?).
Another option I am considering is to leave layouts and on tile press redirect user to a separate Activity with detail view. In this case navigating back seems to be destroying activity and it will need to be redrawn again if user wants to come back to it (redraw is not desirable).
My question is what is better for performance. Each tile as well as detail view might have some images in it and full page will take time to load. But figuring out how to handle this with Fragments programmatically might take a while and the last thing I want to find is that Fragments are not suitable. Maybe you have other ideas for scenario described? Any good tutorials/articles where Fragments are created and managed programmatically completely(no XML).
I am relatively new to Android and completely lost now.
Edit:
Thanks everyone for your advice. I can't choose the best answer at this point. I have to do some more research and learning now. Will do that later.
Fragment should be the best way to go. because filling details in a fragment dynamically is easy. will help check some codes i have written that could solve this
Fragments are a new style in Android for creating GUIs, they should not be compared with simple Activity + xml layout's in performance terms. Fragments were created to make it easier to build complicated GUIs, on both phones and tablets. You can create low performance GUI using both methods.
From your description I suppose its best to create two fragments, and wire them in Master Detail pattern. Master will be your json list with short summaries, and detail will be your additional data fragment. You can still put both fragments in separate activities, and show detail fragment from master one (master actitity will get hidden) - this makes sense on small screen devices. But you can show both fragments on one screen on tablets. See 'Master Detail Flow Template', http://developer.android.com/tools/projects/templates.html.
So fragments gives you a lot of flexibility to modify your UI, without huge code rewrites.
Some new widgets like ViewPager will work only with fragments, so if you want to use it you better invest time in learning them.
From what you have described above you do not need Fragments to do this. On your main page you can use a GridView to display your tiles. You could create two other Activities. One called TileActivity which will open each time a tile is pressed. Then you could create a PopulateActivity which would populate the TileActivity with the relevant information depending on which Tile was pressed. In terms of performance instead of closing the TileActivity to go back to the main page you could use Intent Flags so that the TileActivity isn't closed it is just added to the stack and then restarted instead of recreated each time its called.

Need To Create A Help component in Android

I am building an Android application and would like to include a help component in it. The Help module would have a structure as shown below :
HELP
FAQs
Features
Placing Orders
Online Ordering
Mobile Application based Ordering
Phone Ordering
Managing my Loyalty Account
Signup
Points Catalog
Loyalty Status Tracking
Points Redemption
Accessing Order History
Purchase History
Insights
Reports
Setting Reminders
Helpline
As far as i could find, there are two ways of doing this kind of structure.
The first way would be to use a Multi-level ListView. The problem with this is that the code is quite complicated and that usually ListViews have equal number of child nodes. For example :- in the above mentioned layout "Features" has several children whereas "FAQs" has none. How would that work in a List View?
The Second Method is to use Buttons for all the first-level options and then create individual activity pages for each of the corresponding children. So the first page called "Help" would have 3 buttons as shown :-
HELP
FAQs
Features
Helpline
Upon clicking any one, a new page would open with either more buttons or some text; depending on what the user clicks.
My question is, which of the above two methods is better suited to my application? If there is another way to do this than the two i've mentioned I'd be happy to hear about that as well. I thank you for your time and patience in helping me.
Or you can use this open source project to create a TreeListView:
https://code.google.com/p/tree-view-list-android/
I can suggest the following structure:
The HELP Activity will contain 3 tabs
FAQ can contain the ListView of questions.
Features can contain the ListView with Section Deviders: Placing Orders, Managing my Loyalty Account etc.
Helpline can contain e.g. text and image.
This structure can be created using Eclipse Activities templates: Tabs or Tabs + Swipe or Swipe Views + Title Strip.

Component to add arbitrary number of input fields?

I apologize if I'm just missing the obvious. I'm fairly new to Android development, and while I searched for this particular topic, I wasn't exactly sure what to look for (in terms of a "name").
In an application I'm writing, I have a section where the user can enter the names of players. However, this can range anywhere from 1 to whatever, no limit. However, I'm not sure what the best approach for this kind of feature is, or if there's a component that already does something like it.
Basically, the functionality I'm looking for is similar to what you can see in the Edit Contact screen of the phone book; for the phone numbers and email addresses, you can push a little plus button to add a new number/address, or hit the little minus button to remove a number/address.
I can think of several ways to potentially implement this, but in the end I think wrapping it in a custom component would be best (so that you could call "Get Players" and have it return a list of strings by going through each of the inputs and getting the values).
Am I just overthinking this? Is there a component that does that already? Is there some example code that demonstrates a good way to do this?
Thanks!
Could you just use ListView and add a menu with a "Add Players" option? You could customize the list view to have a little checkbox, for example, and then begin the game by pressing the menu ... or add new players dynamically by pressing another menu button.
After playing around with some ideas, I came across a solution that I think will suit what I'm doing. I created a custom component extending LinearLayout. As part of the creation of the component, it creates a row that says "Add new..." with a plus-sign button. Pressing the plus sign button then creates a new row containing an EditText and a minus-button which will remove the row.
I then created a method for this component called getTexts() which returns a List that has all the non-empty Text values from all the components. Testing it in a dummy app, it seemed to work fine.
I think I need to make tweaks to make it more robust (like the ability to add rows programatically, listeners to alert other components when a row is added/removed, and the ability to set the individual EditText values, for instance), but this functions as I imagined.

Categories

Resources