-2

I show the images on listview and call lazy loadiing in list Adapter class, for the show images on list view it,s working fine . Means Images load properly.

But i implement list view on item click listener and image url pass to another class and again i call lazy loading same as list adapter class

   ` imageLoader.DisplayImage(strimg.trim(), imgview);`

Then error occur

java.lang.NullPointerException

My Java Code

  public class Description extends Activity
    {
public ImageLoader imageLoader; 
ImageView imgview;
String strimg;
Context context=this;
TextView 
@Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.details);

    imgview= (ImageView) findViewById(R.id.descimg);
    try
    {
        Bundle bundle=getIntent().getExtras();
        if(bundle != null)
    {
        strimg= bundle.getString("ImageUrl");
        Log.d("DescImg", "strimg");

    }
    else {
        Toast.makeText(context, "Image"+strimg, Toast.LENGTH_LONG).show();
        Toast.makeText(context, "NUll", Toast.LENGTH_LONG).show();
    }

    Log.d("Desc", strimg);
          imageLoader.DisplayImage(strimg.trim(), imgview);

    }
    catch(Exception e)
    {
        Log.d("DescError"+e, strimg);
    }
}

Pass Image Url

listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                                int position, long id) {
            Intent i= new Intent(PropertySearch.this,Description.class);
            i.putExtra("ImageUrl", strimage[position]);

            startActivity(i);

        }
        });

Please Suggest me How i can fix this problem

Thanks In Advance.

GrIsHu
  • 29,068
  • 10
  • 64
  • 102
Kuldeep
  • 367
  • 2
  • 7
  • 19

2 Answers2

1

You have just declare your ImageLoader class variable

public ImageLoader imageLoader; 

not initialize. So initialize it in onCreate() method like,

imageLoader = new ImageLoader(Description.this);
Piyush
  • 18,895
  • 5
  • 32
  • 63
0

You may be forget to initialize your imageLoader. Just initialize your ImageLoader in your onCreate as below:

public ImageLoader imageLoader;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.details);

    imageLoader= new ImageLoader(this);

}
Piyush
  • 18,895
  • 5
  • 32
  • 63
GrIsHu
  • 29,068
  • 10
  • 64
  • 102