I want to create a program that gets some images from a webpage, and shows them on a gridview. I dont know how many of them exactly. It could be from 20 to 30. Ill do it with asynctask, which i have allready used before and more or less know how it works. But i don't know which way use it this time.
For now, what i would like to get is a progressbar (circle clicking) while image is downloading. And once its downloaded, it would disappear and image will load. I will use an array of objects with an adapter, to fill the gridview.
Which way would you use the asynctask?
Thanks in advance.
I would suggest you check out Lecture 6 of Harvard Extension CS76. There is a URLImageAdapter and example source code that does example what you are looking for.
Best of luck
If you want to save downloaded images and reuse them in future then you must look DownloadManager
To display dialog with cycling circle, look this: howto use ProgressDialog
Related
I'm trying to make a kind of quiz-app relative to the music field where I keep on showing random images and the user takes the answers. For each answer I check in a database whether it is right or not. You can see some examples of what I mean here and here. The problem is that I should put in the Android Project a great number of images, which I suppose is not good. So I'm wondering if there is another way for doing that, maybe using sample-images for each element (a single note, a single sharp, the treble clef etc.) and fixing them toghether in some way in order to "build" the final image.. I really don't know. And also, is there a way to verify the answers without internet connection? Thanks in advance.
You can make a CustomView or views http://developer.android.com/training/custom-views/index.html and have it draw differently, depending on exactly what you're trying to convey. You could use a background as well as images, and draw the lines.
Adding custom View and ImageView to a single Layout explains how to include images in a CustomView .
Before write this thread, I read a lot of stackoverflow thread, and also many tutorial.
I think people maybe some times write tutorial only to "write something".
I use a gridview to show file (imageView+textView) from files
I've got my File's list called files. I set up a Custom BaseAdappter. It worked very well, because rather in a folder I' ve got more than 5 image. So in adapter I can call 3 different method from imageView: imageView.setImageResource(), setImageBitmpa(), setImageUri(). I used the last, because I can call Uri.fromFile(file) after get current file in adapter.
I found big problems when go to "DCIM/Camera" folder. Here, my apps work without crash. Scrool is really fast. This, because I follow all google developer instructions to manage bitmap.
So, now my adater use AsynkTask and also a LruCache. The example by official google developer page use methods where bitma is decoded from resource. So I had to edit some line, and change decodeResource() in decodeFile();
this last method want fileName, and Options. So, my app show "well" all image from default gallery folder, but with a big problem.
After a totally load of gridview, if I scrool down 20 row (example), and return at position 0 scrolling up, many imageView are changed with other image. This problems happens all time I do a little or large scrool.
I cannot post any Log, any Error, because AS not show me any Error. Only some time Log show me something like "WaitForConcurrentGcToComlete blocked..."
Thanks
I am new to the Android development so don't mind asking me simple question like this.
I am trying to implement simple gallery from example http://developer.android.com/guide/topics/ui/layout/gridview.html, but I am not sure how to make clicked thumbnail show in full screen or something like that.
Also, it would be very nice if someone could explain to me how to, in this case, load images from urls via AsyncTask.
Thanks!!
Ive looked into the ViewFlipper, but defining 40 different views in one XML doc just doesn't seem like a bright idea. I know there has to be a better way, I just don't know how. I have spent some time trying to find a answer with no good answer so far.
I have used the Gallery widget (admittedly quite heavily modified) to display 200 fullscreen images in an image viewer for a client.
Alternatively you could use a ViewAimator with either 2 (in this case ViewFlipper) or 3 views (3 if you want to preload both the next and previous images). If you go for this approach then Laurence beat me to suggesting this idea ;) However I'd add that you would want to extend the ViewAnimator/ViewFlipper class to allow it to accept some type of Adapter.
A simple approach would be to simply contain two ImageViews within the ViewFlipper. Then when you request the next or previous view, set the new image resource for the next view and flip.
If you implement a lazy loader using AsyncTask or a Handler this will stop your UI thread from blocking.
Hope this helps!
You could use a ViewPager (included in the Android compatibility library if you need to support pre-Honeycomb devices).
I am sure there is a better way to do what I am doing in my apps. The current one I am trying to improve is a list of military cadences. The way I am doing it now is by loading html files in a web view.
What I would like to be able to do is have one view set up and just be able to add the text portion of what I would be displaying with the html file.
What would be the best method. I know this is probably a pretty simple thing to do with a sting or array but I am at the very beginner level and would need to be pointed in the right direction to do it.
Sounds like you are searching for ListView. You can make a List of what you like tho show to the user and stick that with the an Adapter to the ListView.