I'm trying to create and Android application which requires a number of search criteria which will eventually form an SQL query and run against a database.
The first set of criteria I'd like to present as a 3-tier list where the choices are dependent on the prior choice but there is only one final choice. So you could navigate to commadore via Car > Holden > Commadore. But you may only want to navigate to Car (and see a list of all cars) or Holden and see a list of all holdens.
Car
Holden
Commadore
Berina
Renault
Megan
van
van 1
Van 1 type 1
Van 1 type 2
etc
etc
There will also be other criteria such as colour, place and a free text search, I'd like to present these on a different tab or separate them somehow. I've looked at a tabbed layout but it appears that each tab uses a different activity and I believe that it is complicated for separate activities to talk to each other.
I'd appreciate any thoughts on this as I don't have time to discover all the shortfalls with this that others may have already experienced. Thanks for your help.
Much appreciated.
M
You can create Views instead of activities for the content of each Tab. The Activity which contains your TabHost will then be able to use the values selected from each of the views.
As for the lists, and sublists you can start to look in to the ExpandableListView, however that only provides a two level list, so you would need to look at extending it to allow n-levels I guess.
Alternatively you can have n-number of ListViews and transition between them IF the user makes a selection.
Related
I've read several SO posts and gone through some tutorials and now I'm trying to re-create this: http://i.imgur.com/on2xi72.png However, I'm not sure if what I propose to do is the best way to re-create this layout.
Here's what I'm proposing to do:
I'm working with this well nested JSONArray and JSONObject and vice versa API response (example data: https://jsonblob.com/5525b47ae4b0599c1fbd338b). I was thinking that I would create 3 different types of fragments to show the bullet point data. For example, one fragment would display "High Knees .. 25 yards" Another one could be a hyperlink type like in the case of "Shoulder Shrugs", and the final one would display the chart like the one at the bottom of the image. Since the API response separates data by a title like "Warmup" , "Upper Body Circuit", I was going to create a "block" activity that could contain the title and its related fragments/bullet point data. All of these "block" activities separated by the horizontal black lines would then be placed in another "full view" activity that would display stacked top to bottom. This "full view" activity would then be stored in another array because there are different dates to swipe through (if you notice at the top, it says Tuesday). Also, for each of these layers, there could be any type of variation and amount of data depending on the API call made. I hope this makes some sort of sense, haha.
Thank you for reading my post.
You can have only one activity per screen view in an android app, but can have several fragments per activity. Visual separation of your screen sections does not mean you need to have different fragments per sections in your activity. The reason you would want to use separate fragments is to be able to switch out the content of each fragment independently based on some application logic.
However, - if I understand it correctly - in your case, there is no reason why you would want to use multiple fragments per activity, as all your data is going to be changed as a whole based on the user/calendar day. Therefore, you can just use a single activity, or even better, use one fragment in your activity.
For your reference, this CodePath guide on Fragments may help you better understand fragments and how to use them. If you would like to read up on Activities more as well, you can do so on the android developer guides.
Need an advice about one thing: I'm working on one application, which needs to display a lot of information about some items, which can be of different types with some similar attributes and some extra. Something like this:
Trade Mark
1. id : 211
2. name : Bla bla bla
3. Color : green
...
...
..
44. location
Invention
1. id : 211
2. name : Bla bla bla
3. Category : vehicle
...
...
..
44. location
So all these items are displayed in one List, but when you select one, it should show the more detailed information.
My question is: What is the best practice to display the data? should I create different activities for each category? Or should I create one activity and hide/show attributes related to the particular category? Or may be you can bring me to the light with showing something more effective. Gonna be very appreciated. Thanks! =)
What is the best practice to display the data?
Use a ListView/GridView with ViewHolder pattern.
should I create different activities for each category? Or should I
create one activity and hide/show attributes related to the particular
category?
Its really up to you, using a layout with show-hide method will decrease the number of classes in your project but make the code a little harder to read.
ExpandableListView is the way to go. No need for multiple activities or fragments. If you so wish you can make a fragment that contains the ExpandableListView but that's it - no need for multiple activities. If you are working with tablet's as well, then you might want to have a detailed fragment for the list item details when you click on a particular item. No more, no less, imho.
Lets say I want to create an Android app which shows a list consisting names of 200 people on the main activity. When users clicking on any name, they are taken to a screen showing the available info about that person. The details about each person may vary(some don't have an address, etc).
How will I tackle the issue of 201 different layout files(xml)?
I don't think it will be a good idea to make 201 activities.
If I use Fragments then I'll have to make 200 xml as well as 201 java files(for each different fragment).
If I use layout inflater or view switcher, even then I'll have to make 201 xmls.
So is there a way to strip down the number of layouts that will be required?
Are the layouts for each of the person different aside from the data e.g. address, name, etc. changing? Because if they aren't different you can use the same layout for each one of those people and just load the corresponding data of each person. If you can give me more information about how you store your data and how you display it I can give you a better answer.
No, you don't need that many files at all. In fact, all you need is your main screen containing the list of people, and then a screen containing the placeholder of the details.
When the user is clicked (presumably from some sort of listview) you can pass the details related to that user into the details activity where you can display it nicely, so reusing the same class/activity/layout.
This is a good tutorial showing you the basical mechanism of passing information between activities.
http://www.javabeat.net/how-to-transfer-data-between-activities-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.
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.