I have an android app which displays quotes and have navigation to go to next quote and so on. would like to add "Save Quote As favourite" based on users selection of particular quote.
Once user saves Fav quotes and wants to see those quotes only, app should show those quotes.
Currently app reads the quotes from XML file. Let me know if any more information is required to understand the problem.
I would provide every quote with an ID (int). Whenever the user selects a quote to be a favourite, that ID is saved to a Set of integers. Later on if user decides to show favourites, you fetch all quotes with your IDs from the Set and show them in a appropriate view, for example a ListView
If you have a Quote class or something like that, you might as well put them in a collection whenever user decide his favourites, and show them in a ListView with a custom adapter.
Related
I can successfully retrieve documents from firestore, the trouble is, i do not know how to put them back where they came from!!
My app is a court booking system, it uses 7 fragments that represent the days of the week. Each fragment contains buttons that represent booking slots throughout the day. When a button is pressed, the court booking activity fires showing textviews and spinners.
The information I save to firestore includes a unique number representing a datestamp and a booking id that represents the id of the button that was pressed.... from here, I am lost, i need to write the retrieved database info back to their relevant places but i dont have anything unique in the way of widgets. The buttons are unique but all they do is fire a non unique court booking activity... any help appreciated... sorry for length, quite possibly more to add when answering questions.
To write to a document in Firestore you need to know the complete path to that document. You'll need to track the necessary IDs in your code, in a way that you can synchronize it with your UI elements.
A simple first pass could be to add a non-editable view (e.g. a label) to your UI for each document, and set the document ID (or entire path) in there. Then when the user clicks a button, you find the corresponding view with the ID, and from that can recreate the DocumentReference that you need to update.
I want to dynamically create two editText fields side by side, store information in them and delete whenever I need to.
Right now i have static fields, so it looks like this
Left ones have id siteName1, siteName2... right ones have id siteURL1, siteURL2... Also I have two buttons - Save and Load.
prefsEditor.putString("siteName1_txt", siteName1.getText().toString());
prefsEditor.putString("siteURL1_txt", siteURL1.getText().toString());
and so on...
siteName1.setText(myPrefs.getString("siteName1_txt", "").toString());
siteURL1.setText(myPrefs.getString("siteURL1_txt", "").toString());
and so on...
My app is voice controlled, so when I say command, it checks if I have right website name and opens it.
if (commandList.contains(siteNames[i].getText().toString())) {
mWebView.loadUrl("http://www." + siteURLs[i].getText().toString());
mWebView.setVisibility(View.VISIBLE);
}
Website names nad URLs are put to strings. So my question is - can I add two editTexts and delete them dynamically. Can I save information in them, so when I close and open app - info is saved. Thank you for your time.
in android stuido I would like to code an activity, where the user can input numbers. For, example he types the number to the textfield, click 'OK' button, then the textfield gets clear, he types the second number, than the third, and after they give the third number the program goes to another activity and sayst thanks for the free number. I would like to save the three numbers for further use and have them in an ascending order. How should I do it?
I agree with Andrii, this is a very vague and general question. To get you pointed in the right direction though, you would want a layout with an number based-editText widget (for the user input). I would then add the button, and then implement OnClickListener for the button so that everytime the button is pressed, it calls a method you will define that will store the value in an array or list (which can be sorted), along with some kind of tracker to keep track of how many numbers have been entered - then clearing the editText field so that another number can be input; on the third number, the method calls the activity via intent or some other way saying "thanks for the free number".
This is all general and it is going to take quite a bit of work and API Guide/DeveloperDocs searching on the Android web site.
I have successfully added a word to Android's predefined user dictionary, but i want to create a custom dictionary which can only be accessed by my application.
For example: When i type "lol", the suggestions show me "laugh out loud" but when I want another meaning of "lol" then I can manually add another meaning of "lol" (eg, "xxxxxx" - so the next time the user writes "lol" in an EditText, the suggestions will show him "xxxxxx").
No other application should have access my dictionary data.
I have worked with spell checker class but it gives me only correct word and I can't my own word meanings.
Please give me some suggestions or links.
There is an Androids inbuilt class UserDictionary so that you can add your spells programmatically into that, Here is a link you can go through with , and which may relates to your problem .(In this solution nidhi has manged programmatically to retrieve data back)
Add word to user dictionary and retrieve them back from dictionary
In addition you can go through following links to :
http://developer.android.com/reference/android/provider/UserDictionary.html
http://developer.android.com/reference/android/provider/UserDictionary.Words.html
Moreover if you want a custom personal dictionary then manually you have to store words and retrieve them back .
Hope that helps !!!
hi i would like to know solution for such a problem..... i have an xml file containing users data of around 1000 users listed out in alphabetical order. The xml file use to be as follow
<usersdata>
<user>
<id>1</id>
<firstname>A</firstname>
<middlename>AA</middlename>
......
......
</user>
<user>
<id>2</id>
<firstname>B</firstname>
<middlename>BB</middlename>
......
......
</user>
........
........
</usersdata>
Now from the above xml file i am parsing all the tags and storing them in an array list for each tag. I am listing out the Firstname in a listview, by array list of first name. When the any of the list is clicked, it opens up a new activity where the all other details of the selected name is been shown.
For example if third name in the list is clicked, by using its position(example 3), in the next activity i am listing out the third values stored in all the array lists i am using. This is what currently i am doing.
Now the problem is i have a edit box above the list view, named as a search box. If the letter S is typed in it, then all the names starting with S gets listed first. Opening the next activity by clicking the list now gets some wrong data, how to avoid this.
Please give me a suggestion....
For example if the first name C is clicked, it will be listed at position 3
There is a quick and dirty hack: you can store user id in the invisible field, retrieve it on click and use it as an argument for the second activity. I'm afraid I can't come up with better suggestions without seeing the code.
i tried out by setting some flag and by using an example code in developers site. And i am able to list out the data's but this idea does not full fill my apps requirement in the next activity. So i removed the search part in my app.
Sorry for posting such a question here......