Android lazy images ViewFlipper

I have a problem.

I have fragment with ViewFlipper and some string data array (images urls).

How do I do a lazy load of these images and show progressbar until the image is loaded(And caching them if possible)? Can I use a different view(not ViewFlipper)?

And second question. How do I make a View showing the current image position? Such as a series of white dots with a black under the current picture. If the current image of the first - the first black dot. Thanks.

Answers


Google has a training class answering your first question here. It shows you how to load a bitmap in the background using an AsyncTask and caching it both in memory with an LruCache and on the disk with a DiskLruCache (included in the BitmapFun.zip download found at the link) while displaying a ProgressBar until the image is downloaded

Can I use a different view(not ViewFlipper)?

The aforementioned example uses a ViewPager.

a series of white dots with a black under the current picture.

I do not know if there is such a view available from the Android SDK but this third party widget (Apache 2.0 license) seems to do what you want.

How i can keep link on ImageView and ProgressBar?

I am not sure I understand the question but if you are asking how you go from the ProgressBar (while the image is loading) to the ImageView then the answer is to use a FrameLayout with the ProgressBar and ImageView in it:

<FrameLayout ...>
  <ProgressBar ... />
  <ImageView 
    android:id="@+id/imageView"
    ... />

</FrameLayout>

(see image_detail_fragment.xml in the exercise for more details)

The ImageView will be drawn in front of the ProgressBar but as it will originally have no background and no image it will be transparent and the ProgressBar will be showing.

You then retrieve the ImageView from your code using its id and when you have loaded your image in a Bitmap you use:

imageView.setImageDrawable(loadedImage);

Now that the ImageView has an image it will not be transparent anymore and the ProgressBar will not be showing (you can also add an id to the progress bar if you want to set it to View.GONE to optimise your layout).


Need Your Help

c# loop through combobox where datasource is a datatable with text

c# .net winforms

Is it possible to run through every item in a combobox using a foreach loop? How would I do it?

Does Oracle allow cross schema views?

sql oracle view schema oracle11g

In MySQL, I can create a view which points to a table in another schema. Does Oracle 11g allow this?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.