Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - Issue with lazy loading listview
    primarykey
    data
    text
    <p>I have successfully implemented lazy loading for the listview. Everything is alright; loading of images and text. I have 2 piece of information for text; Name and description. I am able to display flawlessly the image and name. But once I try to include the description in it, it seems alright until a certain position. Program is forced closed at that position. Can't figure out what is causing it to close. Any idea what could be the cause? Results displayed on logcat only prints till about half of total number of items to be print.</p> <p>Program is able to retrieve all images and display them correctly. This is for sure. But having problem retrieving the whole piece of text content. It only retrieves half of the total text available. </p> <p>I am using the example from <a href="http://iamvijayakumar.blogspot.com/2011/06/android-lazy-image-loader-example.html" rel="nofollow">here</a>.</p> <p>LazyAdapter.java</p> <pre><code>public class LazyAdapter extends BaseAdapter { private Activity activity; private String[] data; private String[] text; private static LayoutInflater inflater=null; public ImageLoader imageLoader; public LazyAdapter(Activity a, String[] d, String[] t) { activity = a; data=d; text = t; inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); imageLoader=new ImageLoader(activity.getApplicationContext()); } public int getCount() { return data.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public static class ViewHolder{ public TextView text; public ImageView image; } public View getView(int position, View convertView, ViewGroup parent) { View vi=convertView; ViewHolder holder; if(convertView==null){ vi = inflater.inflate(R.layout.item, null); holder=new ViewHolder(); holder.text=(TextView)vi.findViewById(R.id.text);; holder.image=(ImageView)vi.findViewById(R.id.image); vi.setTag(holder); } else holder=(ViewHolder)vi.getTag(); holder.text.setText(text[position]); holder.image.setTag(data[position]); imageLoader.DisplayImage(data[position], activity, holder.image); return vi; } } </code></pre> <p>Error exception in logcat is shown below.</p> <pre><code>ERROR/AndroidRuntime(270): java.lang.ArrayIndexOutOfBoundsException ERROR/AndroidRuntime(270): at com.lazy.LazyAdapter.getView(LazyAdapter.java:59) ERROR/AndroidRuntime(270): at android.widget.AbsListView.obtainView(AbsListView.java:1294) ERROR/AndroidRuntime(270): at android.widget.ListView.makeAndAddView(ListView.java:1727) ERROR/AndroidRuntime(270): at android.widget.ListView.fillDown(ListView.java:652) ERROR/AndroidRuntime(270): at android.widget.ListView.fillGap(ListView.java:623) ERROR/AndroidRuntime(270): at android.widget.AbsListView.trackMotionScroll (AbsListView.java:2944) ERROR/AndroidRuntime(270): at android.widget.AbsListView$FlingRunnable.run (AbsListView.java:2485) ERROR/AndroidRuntime(270): at android.os.Handler.handleCallback(Handler.java:587) ERROR/AndroidRuntime(270): at android.os.Handler.dispatchMessage(Handler.java:92) ERROR/AndroidRuntime(270): at android.os.Looper.loop(Looper.java:123) ERROR/AndroidRuntime(270): at android.app.ActivityThread.main(ActivityThread.java:4627) ERROR/AndroidRuntime(270): at java.lang.reflect.Method.invokeNative(Native Method) ERROR/AndroidRuntime(270): at java.lang.reflect.Method.invoke(Method.java:521) ERROR/AndroidRuntime(270): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) ERROR/AndroidRuntime(270): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) ERROR/AndroidRuntime(270): at dalvik.system.NativeStart.main(Native Method) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload