1

In my application I'm using Lazy loading technique.I referred this tutorial . In emulator(android 2.1) image is loading,but in device(android 2.3.4) image is not loading.Only android icon is loading.

my getview code:

if (convertView   == null) {
    //this should only ever run if you do not get a view back            
    LayoutInflater  inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    convertView  = inflater.inflate(R.layout.homelistrow, null); 

    holder = new ViewHolder();
    image = (ImageView) convertView.findViewById(R.id.icon);
    holder.text = (TextView) convertView.findViewById(R.id.name_label);
    convertView.setTag(holder);         
} else { 
    holder = (ViewHolder) convertView.getTag();         
}
//       
imageLoader.DisplayImage(kickerimage[position], image);

// holder.image.setImageBitmap(bitmap);
//////       items=itemsarray[position];
         holder.text.setText(itemsarray[position]);

I am totally confused why this is happening in device.Help to solve this.

2 Answers 2

3

This works for me. Try this .

public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
  {

    View localView = ((LayoutInflater)this.topcouponpage.getSystemService("layout_inflater")).inflate(2130903044, null);
    String str = localOfferCategories.getImagelink();
    if (!str.trim().startsWith("http://"))
      str = "http://" + str;
    ImageView localImageView = (ImageView)localView.findViewById(2131099676);
    this.imgloader.DisplayImage(str, localImageView);

    return localView;
  }
}

Also give this permission in manifest file.

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot Pramod J George..<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> This did the trick..Its solved the problem.
1

Test your internet connection before loading images :

if (getConnectionState() == false)
    // ErrorHandling("No Internet Connection Found!! Please Try Later on with Internet Connection!");
else
    // perform further execution

Declare this function :

//To check the internet connection
    private boolean getConnectionState() {
        ConnectivityManager cm = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo ni = cm.getActiveNetworkInfo();
        Log.v("NetworkInfo","NetworkInfo = "+ni);
        if (ni == null)
            return false;
        else
            return true;
    }

Make sure with this permissions :

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Thanks.

3 Comments

Thanks Pratik Sharma..If there is no INTERNET permission means how the text content is displaying??
@Subburaj your app is running in emulator and not in device so it might indicate internet connection issue.
Pratik Sharma..I am displaying image and a text content(which is also fetched from url) in a row in listview.If that text is coming displaying means there is issue with Internet i think so..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.