Gallery(Horizontal ListView) inside a ListView - android

Ok i wasted 1 day of my life i think now is the time to ask for help :D
I have a listview that has an image text ..etc (custom view) and one of its
elements is a Gallery. (Aka horizontal listview)
Gallery also is a custom view.
SO.. here is the problem:
I call the adaptor to set the custom view in the listview.Ok for now.
Inside the listview adaptor i call the Gallery adaptor.Ok for now.
Everything render out as it should be with a very nice complex interface.
Now the problem
When i scroll the Gallery the data change to what the data should have been if i scrolled the gallery of the last listview row rendered.(Hope you get me here)
Ex.gallery in first listview has photos of the sea.
gallery in 2nd listview has photos of a building.
If i scroll the first gallery the photos change from "sea" to building".
Meaning ... each time the listview adapter's getView is called i feed the galleryadapter with data
gal1.setAdapter(new GalleryAdapter(CON,PASS[position]));
What i'm thinking as a possible solution is :
Hardcore , preload all the data in the custom Gallery of each listview.
Figure a way that when i scroll the Gallery element within a listview , the gallery adapter to be aware of the index of listbox and load the correct data.
I think the second solution is more elegant,and more difficult but considering that if i go for the 1st solution there will be >40 views loaded at all times so no biggy.
So.. I;m asking for your help.Is there a 3rd , 4rth .. way?Is anyone of my suggestions even possible?If so please point a way of implement to code.
Keed in mind that i want to be able to do multiple scrollings at any given moment.
So i think that my 2nd suggestiong might have some problems there.

Try using same gallery adapter for all list items and in getView of list adapter just change the data for gallery adapter.
After setting the data in getView just notify gallery adapter.
out side getView(maybe in constructor of list adapter)
GalleryAdapter galleryAdapter=new GalleryAdapter();
in getView
galleryAdapter.setData(CON,PASS[position]);
gal1.setAdapter(galleryAdapter);

Related

load showing image in listview with custom baseadapter

I am working on a android project and i am implementing an adapter for my listview.
My adapter simply load an image and a text together and show them on the listview
but it's not efficient to load all image on cach.
So i'm looking for a way just to load image which are shown to the user on listview and every time the user scroll up/down the images of list being update
Is there any way to do this?
thanks in advance
In List View, getView() method of the BaseAdapter is called for only those views which are shown currently on screen. So you can use Nostra Universal Image Loader library to load the images asynchronously.

loading images in autocompletetextview suggestions using custom cursor adapter

I am working on an app which requires an autocompletetextview for suggesting contacts in dropdown view. I am using a custom cursor adapter. My layout for one drop down item has imageview on the left (for showing image of the contact if available, else a default image).
I have used Asynctask to load images from the contacts. In my bindView method, I have following snippet to load images from the Async task.
contactImage = new conactImage(viewHolder, cursor);
contactImage.execute(new String[] {userId});
and in the Asynctask's onPostExecute method, I set the image bitmap.
mViewHolder.cImage.setImageBitmap(imageResultBitmap);
mViewHolder is the viewholder passed as argument in the previous snippet.
The problem I am facing is a bad UX. Suppose I entered two characters in the autocompletetextview. The images show up in a second. When I scroll, the images don't change unless I wait another 2 3 seconds to get the correct image loaded. And when I scroll fast, the views flicker a lot because of the random image bitmap changes.
I understand it is a view recycling thing, but this gets annoying. Please suggest any other possible way to do the same.
on scrolling
Thanks!

Endless Adapter with custom listview adapter in android

I am using this link to create custom listview in my app.
First I want to display listview with 5 items. As I scroll the list it should parse data and load listview for next 5 items.
Listview row contains 5 textviews.
How can I achieve this?
Please help me.
Thanks in advance
I want to display 5 items in single row
That has nothing to do with EndlessAdapter. That has everything to do with the ListAdapter you are putting into the EndlessAdapter. Start by not using EndlessAdapter and getting your list looking the way you want. Then, and only then, add in EndlessAdapter to add more data to the list as the user scrolls.
There are countless examples online of how to create rows in a custom ListAdapter that have more than one thing in them. Here is a free excerpt from my book on how to subclass ArrayAdapter, override getView(), and handle more than one widget in a row. You specifically will want to look at the "Customizing the Adapter" section.

Android - Displaying Image and Text dynamically in ListView

How do I implement a listview which displays images an text dynamically from the web? Each image has some descriptions to it and I need them to display correctly in each list. The images change every once in a while. So I have to retrieve up to date contents.
I have read this, but have no idea how to include text into it. Any help here?
Thanks.
Here you will find full details and along with Full working Source code
Android lazy image loader example
Use an ListView Adapter like here: http://android.amberfog.com/?p=296.
The getView Method is executed for every row of your ListView, so you have to place your code to load the images right there
When the Data changes simply call notifyDataSetChanged on the ListView Adapter and the ListView will refresh (executs getView again).

gridview load remote image . updating view?

I am using a GridView having image as child items.
The getView functions loads a default image from the application "Loading.gif" for all the child items.
In another thread I load all the images to some Bitmap type into the adapter.
Is it wise enough to call adapter.notifyDataSetChanged() after each image is loaded ?
Or is there and alternative way to directly update the image ?
Checkout the technique used in ListView , where default image used in listview items. And a thread load images for list items and update the new images without adapter.notifyDataSetChanged() called.
http://iamvijayakumar.blogspot.com/2011/06/android-lazy-image-loader-example.html
If you want more efficient way to do this then check this out.
http://developer.android.com/resources/samples/XmlAdapters/src/com/example/android/xmladapters/ImageDownloader.html

Categories

Resources