I know how to setup a listview to have an image and some text on each rows.
I know how to have the user open up a dialogue to pick an image from the file system or live.
I almost know how to downsample it in case its huge. (too many ways, no expert to recommend one).
I really need to know how the user can create db entries (notes) that contain text and an image that is user selected. In essence, the user is entering text and selecting/uploading an image that makes a 'note' and the notes get displayed in a listview.
I don't want the full code, but rather a general direction. I did some research and for me its a big forest. If you can give general directions how thats done, I'll do the rest.
Thank you,
Related
I'm just getting started and trying to make a simple app after going through some of the Google Codelabs. I wrote a Choose your own Adventure type of game. It consists of 500 paragraphs, and at the end of each paragraph is usually a choice of the next action to take (ie paragraph to load) and possibly some game logic. For now I am concentrating on the text only.
It seems simpler to make 500 text files and load up whatever file number is necessary, however it makes more sense to load ALL the paragraphs as the entire text takes up roughly 300Kb as a text file.
How would I even attempt this? I know I would need a text array and I file reader. I think it would be more work to format the paragraphs with a delineator to separate them, as it may be simpler to just create 500 files and write a While loop feeding my array.
That should fulfill my current objective, but when I want to add the choices at the end of the paragraphs, it seems as if a JSON or XML file that includes the text and choices would be better. I could not figure out how to even attempt this.
Example Paragraph: "You hear a horseman galloping and spin towards the sound. Do you have the skill of Forest Stealth? If you do, turn to 95. If you do not, turn to 234."
I have a list of image URLs and have to show them and change them automatically in ImageView and need to count how many times every image appears to the user.
What could be the best approach to do this? can we avoid handlers here?
Android provides views which can be used to display images from various sources and provide transitions between them. Some of these views are the ImageView and the ImageSwitcher. These views provide a high level of functionality to display images in a user interface so that we can concentrate on the images we want to display rather than taking care of rendering.
You can get complete guide setup in links description.
In description there is a complete explaination for changing image using ImageSwitcher
by pressing a button, But by updating the code to change after certain can be done easily.
Link to tutorial:
https://www.sitepoint.com/handling-displaying-images-android/
A github link for application used with image switching button:## Heading ##
https://github.com/Adarshgkp04/Android_Image_transitions.git
Feel free to ask queries.
I'm making an ListView in my app which over time could contain hundreds of items. Are there any "best" methods of loading lots of data?
My idea is to load it in chunks (say 10-20 items). Load the first chunk, then when the user is about halfway through scrolling, load the next chunk, add it to the bottom of the list (and make sure the list scroll offset doesn't jump about).
Some other ideas I had just didn't like so much were accepting the cost of a large http call and load all the data at once, but just load it in chunks as they scroll, or maybe add a "Next x items" button at the bottom, or loading all the items into the list at once and having one large list I don't need to keep track of.
I personally like my original idea, I was just wondering if there is a preferred method or doing this, and if there are any performance issues I could have.
The data in question will be a JSON string, and each item will display some title text, a date, the author of the item, and an image which will be downloaded using the Picasso library.
Your initial idea is my preferred approach because it works very well in most situations.
The second one may work well, but the problem is, the "large" data concept is relative across devices. For powerful devices you may load 2000 items at once, but it will kill older, slower phones. Also, if you're loading 2000 items when the use case of that ListView is to choose one in the first 100, you are wasting bandwith.
The first approach is very scalable: You really don't care if there are 5 items or 50 million, you just load chunks as the user consumes them. The memory usage is consistent. Coupled with ListView's view recycling, this will have a small memory footprint.
To say something positive about the second approach: Maybe in a use case when the ListView always has the same data, and it rarely changes, for example, an image library, you may want to load all the data at application start and cache it, so you never have to do network requests while the user is using the app. If the data size is not huge, I'd go for this second approach. But always having in mind that there's a critical size after which you will need to page!
Basically you can load all items once and show them all (if you will use ViewHolder pattern and lazy image loading using Picasso - everything should be ok). If you have some business logic which force you to show data by pages - you can follow the way that you described first.
If you will show all data - you can add search by list for better UX(you also can do it when you have pages but it will be more tricky).
Some time ago I wrote an article on similar topic:
http://developer.samsung.com/android/technical-docs/Batch-loading-list
The article comes also with a small library of common classes.
Maybe you will find it helpful.
Cheers,
I have been looking for a while but haven't been able to find an answer. I have a text view in my APK that needs to potentially handle large amounts of text being appended to it a little at a time. So it could grow over time as stuff streams to it. So far I haven't seen any issues and I have let the underlying Android implementation take care of the data. Does anyone know if Android caches these all in memory or that if it passes a watermark level it could then write to file for the TextView? What if it gets too huge, would the APK run out of memory and get killed by Dalvik? If that is the case I am open for any suggestion as how to mitigate this possiblity. One solution in my mind is that have a custom textview that does exactly what I explained and caches data to file if it passes a water mark. However, I am not sure how tricky it would get to detect where the user is navigating within the TextView to pull the data back and forth from the underlying data file and populate the actual TextView object.
Thanks
While I was unable to find the actual threshold, it has been discussed and suggested that extremely long text be displayed in smaller chunks. You can also write to a file which you can then read back in as necessary for your project.
Edit: regarding the TextView bookmark (for lack of a better term), you could always programmatically check to see where the user is in the TextView (checking for a certain character or string at the end of the TextView) and reading the next few lines of text into the TextView. You would have to match the getText().toString() value of the TextView against the readable text in your file.
I'm wondering now too if you would be able to do that in either direction. To save space, you could write your text to file as the user needs it, and update the TextView to only display 5 or 6 lines (arbitrary number). You could trim the TextView in either direction to save memory. You could ellipsize both sides of your text, scroll enable it, and trim/read those points as necessary.
I would like to program an image that the user can press which will display another image when touched to give the user more information but then revert to the previous image after the user stops touching the image. I would also like to add vibration and a ding sound (which I have) when the image is touched. I looked into this but found someone else with the same problem who couldn't help - they said only one of the actions was possible. Help?!
Oh, and if you're feeling extra kind.. Is there a way to configure the amount of time the extra info picture stays when the user stops touching the image?
Thanks
Have you tried any coding at all before asking how to do it? Also, rather than asking how to do a whole project you should ask the parts you are having trouble on once you've actually attempted it...