I have a button on my home screen that will add an edit text field every time it is pushed (I limited it to 20 for best practice). It is basically a small budgeting app. I want the user to fill in an X amount of dollars in one of the fields. Then, when they are ready, to come back to the app another time and that created EditText is still there filled with the value. I know how to utilize SharedPerfrences to hold the value. I do not, however, know how to hold that newly created EditText field when the user comes back.
I am acutally going to expand and have a button and a datepicker associated with each EditText field so soon click the button will create three objects, not just one. But I want to get one working first and will apply the principle to the others later. Any suggestions?
Sounds like a good candidate for a SQLite database.
For instance, I use a SQLite database to retain and recall the co-ordinates and types of widgets that the user has arranged within my application.
Note that you don't ever want to be trying to store and recall the actual EditText View object itself. In your database you need to devise your own table format that suits the kind of information you need to store. If you simply need to retain the states of a series of EditText fields then this could be as simple as having a table with just one column that contains a string value on each row. To build your UI up again from that database, you'd loop through and create a new instance of EditText, and set the text of each one from the table.
You would have to use Android Parcelable interface, refer to this to know as of how to implement it, refer to this question which I has asked on StackOverflow, it has a good answer.
Related
I'm working on an application that should allow the user to tag a user onto an item. In Google Drive, for example, when you're entering users to send an item to, the user's name becomes it's own "view" in the textview so that it cannot be modified and broken.
My current implementation already contains an autocomplete registry of current users, and formats the usernames with html tags so that they're interpreted correctly by the backend, but it's still possible to tamper by moving the cursor to the center of the name and modifying it.
I would like at least an example of how to accomplish what I am trying to do. The problem itself is hard to search for, probably because I just don't know what to call it.
Example of what I'm looking for: http://imgur.com/EBDoWED
Eventually, I came accross this: https://plus.google.com/+RichHyndman/posts/TSxaARVsRjF
Seeing that they're called "chips" is making this a lot more researchable. I'm still a bit weary about what I'm going to do, but I've got enough resources to start.
I'm going to attempt to make a LinearLayout that dynamically contains "chips" and edittext views and handles most of the functions of an edit texts.
I need an advice about ListView.
A give you an example:
Assume that i have a map. If i'll touch some place on it i'll get an information about that place and then, on screen, a dialog fragment will appear. In this dialog i can write a name of place, which i touched. The names should be saved into ListView but if i'll click on some of them i want to get information.
Can some of you tell me how i should do this? Is it possible to save that information in Shared Preferences?
Maybe you would get it work with SharedPref. but it isn't a nice way to that. I think the best way is to create an Android SQL-DataBase. Like in every other Database you could use one column for the name, one for the information text, one for coordinates and so on (that's just an example). The data will stay, also if your app is closed (like SharedPref).
New to android development. I recently finished the lynda.com tutorials, but want to get more involved. I was thinking about doing an app that shows various quotes from movies, but am in need of some guidance. I just want it to have one activity and am going to have a next and previous buttons at the top. How would I create the app that shows quotes in a randomized order and keep the quotes on the same screen?
Thanks for any and all help!
Create an SQL Database and store your strings in the table and display it using list view.
http://www.androidhive.info/2011/11/android-sqlite-database-tutorial/ - tutorial for database.
Your request is essentially just a basic layout question: Create a basic view, lay it out with a text field and two buttons. Create either an array list of strings or an SQLite database (as detailed by user3245033). You will then need to add listeners to both buttons (http://developer.android.com/reference/android/widget/Button.html). The next button should generate a random number that becomes an index into the list or database storing your quotes, the back button should store the previous index value (so that you can go back to the same quote as opposed to a random quote). When you're retrieved your quote, set the text field to that string.
There are many basic examples that demonstrate this type of work. mybringback on YouTube particularly amazing:
http://www.youtube.com/playlist?list=PLB03EA9545DD188C3
I am working on app which have data entry form which have
Some fields with 3 drop down associated to it.
More then 25 input fields (input box, radio button, drop downs etc)
All input fields are grouped into 3 categories
My question are:
How to display field with 3 drop downs associated with it ? Because of a small screen size it cannot be displayed horizontally.
What is the best way to represent 25+ fields ? I tried scroll view and tabs but don't find it so pleasing.
For example if you consider date then it may have three drop downs for date , month and year. (Its just example I have fields different than date)
What is the good way to have fields in a category together with appealing UI.
PS: My app is related to Hospital so it has to be pleasant .Which also means I cannot use glossy background or image.
You might want to check this site for general Android UI design ideas. Here are some for your particular cases:
re-design your UI to only show what is needed. It's unlikely that all 25 fields are used all of the time. Consider separate screens for different use cases, and/or some sort of wizard-like UI (fill in the basics, press next, fill in details, etc.)
if you really need to display all of this, consider using a tablet, not a phone to run the app (assuming this is to be used in the field, and you have some control over devices).
instead of tabs, you might want to try something like ViewPager. It doesn't take as much space as tabs, and the number of views is practically unlimited.
Maybe like this...
You can use the library QuickAction which allows to create some kind of context menu.
To keep a simple screen view, you can only display the current values. Several on the same lines for the same category.
Then, if the user click on a value or category, you trigger a QuickAction with the actions available for the category or values: Edit, clear, ...
For each action, you can also show a dialog to update/fill the field which has triggered the action...
I am writing a custom calculator Android app. Basically, I have five edittexts, a calculate button and a reset button. I have hooked up the reset button so that onclick of the reset button it sets the value of all five edittexts to "".
How would I go about getting the values of all the edittexts on calculate button click and making an algorithm? Since there are five values, would I need to save each to a sort of temporary cache string?
I am really, really new to this so very plain english is preferable.
Thanks for any reply.
If what you're trying to calculate is a sum, then you should iterate through the Edit Texts (which you can conveniently save in an Array or a Collection... I'd rather go for the Array actually), and, well, add it to the previous value in an auxiliary variable.
I don't get where is the problem. Maybe I'm misunderstanding something. Seeing your current code could help.