Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid-Universal-Image-Loader :: Loading images on GridView
    primarykey
    data
    text
    <p>I am trying to develop a wallpaper application. When the application launches, an activity shows the categories (an image and corresponding name on a textView) on a gridView. When I select a category, it navigates to a sub-category. In sub-category activity, it also shows subcategory image with its corresponding name on textVew. Problem is in sub-category activity images are not loading. Sometimes it loads a image; when i press back-button, then select that sub-category again, it loads three mode image; pressing back button and selecting than sub-category causes loading another three images (now its total 10 images). The images is cached on the disk properly. Here is my configuration:</p> <pre><code> cacheDir = new File(Environment.getExternalStorageDirectory(), "peakwallpapers/cache"); // -- // Create configuration for ImageLoader config = new ImageLoaderConfiguration.Builder(this).enableLogging() .discCache(new UnlimitedDiscCache(cacheDir)) .memoryCache(new UsingFreqLimitedMemoryCache(2000000)) .denyCacheImageMultipleSizesInMemory().threadPoolSize(10) .threadPriority(Thread.MIN_PRIORITY + 2) .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) .build(); // -- options = new DisplayImageOptions.Builder() .showStubImage(R.drawable.stub_image) .showImageForEmptyUri(R.drawable.image_for_empty_url) .cacheInMemory().cacheOnDisc().build(); imageLoader.init(config); </code></pre> <p>Here is the getView() methood:</p> <pre><code> @Override public View getView(int position, View convertView, ViewGroup parent) { final View rowView; final ViewHolder viewHolder = new ViewHolder(); if (convertView == null) { rowView = getLayoutInflater().inflate( R.layout.item_sub_category_grid, null); viewHolder.imageView = (ImageView) rowView .findViewById(R.id.image_item_sub_category); viewHolder.textView = (TextView) rowView .findViewById(R.id.text_item_sub_cat_desc); rowView.setTag(viewHolder); } else { rowView = (View) convertView; } ViewHolder holder = (ViewHolder) rowView.getTag(); holder.textView.setText(wpSubCategories.get(position) .getSubCategoryName()); imageLoader.displayImage(imageUrls[position], viewHolder.imageView, options, new SimpleImageLoadingListener() { @Override public void onLoadingStarted() { showLoading(); } @Override public void onLoadingComplete(Bitmap loadedImage) { Animation anim = AnimationUtils.loadAnimation( SubCategoryGridActivity.this, R.anim.fade_in); viewHolder.imageView.setAnimation(anim); anim.start(); } }); return rowView; } } </code></pre> <p>My Grid layout: sub_category_grid.xml : </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gridview_sub_category" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:horizontalSpacing="4dip" android:numColumns="2" android:verticalSpacing="4dip" /&gt; </code></pre> <p>and My item of grid: item_sub_category_grid.xml:</p> <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/frame_l_item_sub_category_item" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight=".5" android:background="@drawable/textlines" &gt; &lt;ImageView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/image_item_sub_category" android:layout_width="fill_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:contentDescription="@string/descr_image" android:scaleType="centerCrop" /&gt; &lt;TextView android:id="@+id/text_item_sub_cat_desc" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:background="@drawable/cat_bg" android:gravity="center_horizontal" android:text="TextView" android:textColorHighlight="#656565" android:typeface="monospace" &gt; &lt;/TextView&gt; &lt;/FrameLayout&gt; </code></pre> <p>N.B: It shows no error on LogCat.</p>
    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