Building a simple android quote app - android

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

Related

Can you use a search widget to search for text in android:text="______" fields?

I'm building an app with linear and relative layouts to create lists. I want to have a search function to search through text fields and return the results with "links" to the pages it pulls the results from.
I don't know if I am explaining this well enough, but that's what I need help with. I can find all sorts of search help but it all seems to revert back to ListView's.
You should aim to create your "lists" from some form of data-store. Usually a database, see SQLite Databases in Android. You should then use the query language to return only fields that match your search term e.g. "SELECT * FROM people WHERE name = 'Adam'".
To directly answer your question, the searching of text fields (EditText's or TextViews) is not possible to do automatically and you would need to hard code the search for each individual one.

Implementing AutoCompleteTextView/SearchView with autosuggestions over large dataset

I would like to ask if my concept of implementing search in my application is correct and whether it could be improved. I will provide any details needed therefore I believe my question is well-suited for this site.
I need to implement a search over large SQLite tables (~20 columns,
possibly 1000-1500 records - you can think of it as a catalogue of
items in a supermarket). The search should be performed on more than
1 table (i.e. 1 catalogue) but I can also force the user to choose
specific table (though I would like to avoid it).
To make the search efficient, I'll use the SQLite FTS3 tables.
I want to make a fast search that will quickly show results as the user types a query string. For example, when a fragment of
product manfufacturer is entered all of the products matching that
string should be shown. The perfect solution would be if the user
could enter fragment of one column and fragment of another at the
same time, though I think that could be a little too much for an
Android device.
Questions:
Should I use a SearchView together with a a ListView (and show search results in the ListView) or should I use the AutoCompleteTextView?
Are the FTS3 tables the right way to go (i.e. will it be fast enough) to effectively perform search over several (large) tables?
I am targeting Android versions >= 3.0.
If you want to have a few line of code, you should use AutoCompleteTextView for it has ready built-in listener (ontextChangelistener -- wherein you can show the suggestions every time the text changes ) and list/ container for suggestions.You can create your own adapter to customize the design of the list.
FTS3 or FTS4 would be great in querying big amount of data.

ListView, storage 2 columns [android]

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).

Android: How to put each tuple returned from a SQL database as text on a button?

so I am making this app which currently connects to an external SQL database with a list of item names (I use php and json for this), and it displays these names as a textView. I followed this tutorial to learn this:
http://www.youtube.com/watch?v=4Soj22OMc98
However, what I really want to do is have the app have a button for EACH of the item names. Is there a way to make my app such that for each item name it pulls from the database, it creates a button, with the item's name as the text on that button?
This is very do-able. For each item name retrieved from your database, you need to programatically create a button and set the text attribute to the name.
Button b = new Button();
b.setText(insertNameHere);
Of course you also need to set the position of these buttons as well. This resource gives a good tutorial for creating buttons in this way: Tutorial

How do you save a (user-created) dynamic Layout in Android?

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.

Categories

Resources