As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I know there are questions about sql databases, and things like that. i have been searching through the site for something that'll help, but it's only confusing me further. I'm reluctant enough to ask here, as the last time i asked for a nudge in the right direction, the question got closed because i didn't post up code.
I'd post some if i even knew where to begin.
But i digress.
I'm looking for the best (easiest?) way to do this:
Small interface, drop down menu with list of names, when a name is selected, it shows a small list of details about the selected name.
here i mocked up the basic idea in dreamweaver:
ideally it would call up the user info as needed.
I have no idea how to make something like this for android (or..at all really). Would anyone have any tutorials or can you point me in the right direction?
Thank you to anyone who can help.
Well, if you don't know anything about Android, how about doing some basic HelloWorld tutorials?
Anyway, you'll have to make some class that holds the info about your users (Location, Phone etc).
The dropdown thingy is called a spinner in Android, learn about how to put it in your layout, how to populate it, how to react to an item being selected from it.
Then think about how you want to present the info on the screen, learn about XML layout, TextViews etc.
We won't code this for you and it won't code itself, just start somewhere.
To start developing for Android, you could try the Getting Started tutorial on the android.com site: http://developer.android.com/training/index.html
I think you have the first step done. To me, if you can visualize and draw out what you want, the next step is to just dive head first into the code. You will learn, just don't be afraid to do some internet searches first.
First of all, I always recommend that new Android developers look at the Android lifecycle to understand what happens where. For your application, you should understand what an Activity is, and what happens in onCreate(). Do some reading and try to grasp what an Android Activity is.
Next, you should look at working with Android Layouts. This will help you put something on your screen. By default, a basic layout.xml file is generated when you create a new Android application in Eclipse. Use this as a basic framework for dropping Input Controls on to the screen. The specific "drop-down" functionality you are looking for can be found in the Spinner control.
Once you have a Spinner on your screen, you can then fill it by creating an Array of values that you would assign to an ArrayAdapter. This ArrayAdapter then gets associated directly to the Spinner to fill it.
Use the Android Developers site, it is very useful. They have tutorials and sample code in the SDK as well.
This answer should have plenty of terms, links, and direction for you to get started.
Update:
I would like to expand on my answer to be more specific, but I think I need a little more information. For example, are you pulling these names from anywhere specific (ie. the device itself?). Regardless, the names have to be put in the form of some type of array, either a String Array or an ArrayList. This is only because that is how ArrayAdapters work and ArrayAdapters are what populate Spinner objects. So I guess what I am trying to say is that regardless of how you get your names, you are going to have to organize them in some type of array to put them into the Spinner (if you want to keep it simple of course).
Now, once you get the names put into your array and you can click the Spinner to show them all, you now want to trigger an event that pulls the data you would like to show beneath it. I would recommend doing this in 1 of 2 ways. You can select a name from your Spinner and then hit a button to initiate a search for the other information you would like to show. This would be a better solution if you are pulling the data on the name from a network resource. If you are pulling the data associated to the name selected from the actual device (either a SQLite DB you configured or an Android system DB), I would just use an onSelectionChanged listener on your Spinner. You can do that by using something similar to this answer:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Spinner spinner = (Spinner)findViewById(R.id.mySpinner);
// create your arrayadapter of names and then set it to your spinner
// then add a lister to look for a change
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
// update your view with the information for the selected user
}
#Override
public void onNothingSelected(AdapterView<?> parentView) {
// do something
}
});
}
Once you can register a change in the spinner, you can then just initiate a query to determine what information to display. If you create a custom DB with all of the information associated to names, you have to create your own DB handler. If you pull the information from a network resource, make sure that you put your networking operations in a background thread, or AsyncTask. If you are pulling the information from your Android device (contact records or something), just use Android's build in functions, libraries, and API's. I would try to keep everything localized instead of having to depend on a network connection.
Once you have all of the information, you can dynamically create layouts and add them to your current view or you can just have a single layout that you change occasionally and to show and hide. Both of these solutions are completely reasonable, and I don't believe one is necessarily better then the other. I used to be a fan of just making objects invisible and showing them when I needed them, but I am getting into programmatically creating layouts on the fly when I need them. This seems to be a little more difficult for new Android developers though, so don't feel bad if you have sketchy if/else statements that just show and hide XML layouts.
Anyway, hopefully all of that helps!! Welcome to Android!
What you are looking for is an Android simple CRUD application tutorial, google it.
(Well, assuming you've got a basic android development knowledge...)
sample of result : http://www.theserverside.com/discussions/thread.tss?thread_id=62177
These are some useful tutorials that can be found via Google.
http://commonsware.com/Android/
Related
first of all I want to thank, because in this community I have found a lot of solutions to my development question. But this time I have a big one. I was looking for an answer to it in google and pdf´s and so on. But it's a complicated question and don't know how exactly ask for it in google. I new in app development. so here I go. I'm trying to do an app that shows the different recipes with photos and description like time that it takes and the difficulty and so.
explanation of the question
Apologize because the childish imagen to explain to you but you know (efficiency).
My two questions are:
1) How may I do to attach a description to an image. I mean, I want that the people can add their own recipes and of course I will make a formulary to this, but how may I do to when the people create the recipe that I suppose that it should be an object of a class, the TextView be attached to the bottom of the image automatically. in resume, that the image and the description with their elements be one unique element. I have tried to encapsulate the image and the text view in one layout, but in this case I don't know how to create a new layout once the app is running. ok the user fill the formulary but how to create a new layout on the run. I don't know how to solve this.
2) How may I do to change in the description of the image the quantity of red tomatoes. I mean. if the recipe have 3 in difficulty, 3 of 5, this is settled by the user, but how I do to show 3 red tomatoes of 5 and the other showed in gray?
I know you may say "another Newby" but I have realized that I love programming and in El Salvador (Central America) there´s almost any information about this subject. Again, thanks a lot.
one way to achieve that is by using Recycler view. and every time a user adds an item. you can add it to the list and the system will draw a new item for you.
check this tutorial
let me know if this helps or you need more explanation
Long post ahead...
Ok, I'm not sure how to explain it so I made a couple of screenshots. Also, I want to start off by saying I'm not looking for somebody to write code for me to copy, or links to specific articles. I just need help figuring out if what I want to make is possible and any direction on what to look at. I just haven't done something like that and so far I can't seem to word my searches well enough it seems to be able to find a solution.
TL;DR: I need to get scrn2 to either swipe left and right to prev/next card from the RecyclerView, or add buttons that do that
So. Here's the screenshot. I have already made scrn1 and scrn2, and am looking for a way to get to my mockup (that heart button there is just wishful thinking and I'm not at all concentrating on it, and the buttons on top of the cards are just a left-over from an old test I forgot to remove).
The idea behind this is just sort of a catalogue/text book to help with self-preparation for an exam on a specific topic.
What I have is a RecyclerView that I've populated with CardViews in an ArrayList. Since I'll be having a few cathegories of cards, and each will have around 40-50 in there, this seems like an efficient and quick way to load a long list like that, and it runs smoothly so far so I'm happy with it.
In order to get a "full details" screen (scrn 2) I implemented Parcelable to my single item template/class, and now when I click on a card I get that second activity that shows the full sized image, title and full description text.
I also added a search that filters the cards in real time, since there will be many of them and I want it to be easy to get to a specific item.
So far so good. Everything works, surprisingly.
Where I'm stuck now is that it will be extremely annoying for somebody to keep going in and out of the single items in order to get to the next one, so I need to be able to either make them scroll or have buttons at the bottom that go to previous and next. The thing is, the only time I've used swiping is in a tabbed activity and that requires fragments. When making those I had to have an xml for each tab, and a class to correspond to it, which is definitely not comfortable when I have 40 in 10 categories.
I assume I need something like an onClick event to add for buttons in the activity that holds the information that gets acquired from the RecyclerView to bring a specific position from my ArrayList... Like, if somebody clicks on the third card, the button brings -1 or +1. Or something like that?
Makes some sense in my head, but I can't find a way to search for that, and can't figure out if it's even possible to make. Soo any pointers would be hella useful. I'm really excited about being able to do that much from scratch, but still lack too much knowledge to be able to imagine what would work here. I'm still testing things out and am looking around for information, but will be happy if somebody has input on the situation.
I'm trying to get the same item as Window's combobox in Android java. I realize there's a spinner but what I need is to display a scrollable list of items that the user can simply select one or more. The spinner is nice, but it's a totally different beast.
Is there an equivalent? Because otherwise I guess I would have to create a section of text items, that I would have to build my own scroll function as well as selection. Hoping to avoid all that.
Thanks.
You're going to have to write your own, or find a library. There is no builtin equivalent. Luckily it should be easy, you basically just want a recycler view where the adapter keeps track of what items you've clicked on. That will take care of the scrolling, and the display simplifies to a normal list adapter.
Import third-party library just for little feature is unnecessary, you could try change spinnerMode to dialog, then the spinner is scrollable.
Edited:
sorry, I noticed that you need select multiple items, my answer is not suitable. You could create a custom widget.
The easiest solution is using library. There a alot library you can use for that problem. Here is the some library you can used:
https://github.com/prsidhu/MultiSelectSpinner
https://github.com/pratikbutani/MultiSelectSpinner
Or you can follow this tutorial
https://trinitytuts.com/tips/multiselect-spinner-item-in-android/
Hope it help
I have been working on an app that adds views programmatically to a linear layout.
The problem is if I add too many views it will go off the screen.
I would like to know how to check if a certain child has hit the end of the same view group so I could add it into another layout (a linear layout below the first one) before it "flows" and go off the screen. How might I accomplish this?
Rather than reinvent the wheel yourself, I suggest that you check out the FlexboxLayout project by Google: https://github.com/google/flexbox-layout
A FlexboxLayout will automatically give you the behavior you're describing, plus the potential for much more.
Well, there are a good number of ways you could implement this in android other than going through this hustle. What ever you are trying to do at the moment may fall under one of the following cases.
Creating views programmatically most likely means you have a dynamic data set probably from an external source.
Your dataset is limited or static but just more than the average screen can display.
if any of the above apple then you are better off using a ListView or RecyclerView (Recommended). That way your data is full displayed as a scroll-able list and you don't have to worry about some items or views not showing or going of the screen. This can range from simple string list to complex nested views.
This will be very efficient as it will automatically handle optimization and usage of memory as well as performance.
It is possible to implement following UI using ListView in JavaFX:
(Since I do have enough reputation to post a image, it can be found here)
Which means not only the titles, but the dates and status(synced or not) as well.
The information in the ListView should be read form a ObservableList<CustomObject>. Each CustomObject has its properties including title, date, status, etc...
Finally, I will need to add a listener to it.(This won't be a big issue I think).
Again, thanks very much. Since my level is pretty low and I am possibly asking some stupid questions, I kindly ask you if you can explain with some actual codes.
Or, if a ListView cannot do such a thing, what else should I use?
What about using a VBox for the lines?
Then for each entry an other VBox with two entries for the two rows (one for the title and one for the date/status).
Title, date and status -> label
If you want to drag your scene together you can try:
https://docs.oracle.com/javase/8/scene-builder-2/installation-guide/jfxsb-installation_2_0.htm