I just wanna make my imageview load from url when it click then displaying in another activity.
Here my adapter class
private void openDetailActivity(String name, String propellant, String desc, String imageUrl)
{
Intent i=new Intent(c, DetailActivity.class);
//PACK DATA
i.putExtra("NAME_KEY",name);
i.putExtra("PROPELLANT_KEY",propellant);
i.putExtra("DESCRIPTION_KEY",desc);
i.putExtra("IMAGEURL_KEY",imageUrl);
c.startActivity(i);
}
then opened in Detail acitivity with this code
Intent i=this.getIntent();
String imageurl=i.getExtras().getString("IMAGEURL_KEY");
touchimg = imageurl;
and i make setonClicklistener, when it clicked so the image can load with full size in another layout. Here the code
Intent i = new Intent(DetailActivity.this, enlarge.class);
i.putExtra("IMAGEURL_KEY",touchimg);//PENTING UNTUK AMBIL DATA
startActivity(i);
And the last, this class below for catch url image to display enlarge.class
String touchimg = getIntent().getExtras().getString("IMAGEURL_KEY");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single_touchimageview);
ImageView imglarge1 = (ImageView) findViewById(R.id.imglarge);
Picasso.with(this).load(touchimg).placeholder(R.drawable.placeholder).into(imglarge1);
}
And i got error with this log message :
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.newsapp.unair.rizki.enlarge.<init>(enlarge.java:18)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2116)
How can i fix it?
i've check with Log.d, when i put Log below get,Intent like this
Intent i=this.getIntent();
String imageurl=i.getExtras().getString("IMAGEURL_KEY");
touchimg = imageurl;
if(touchimg != null)
Log.d("TAG", "tidak null");
else
Log.d("TAG", "image null"):
and the Log said "tidak null" or not Null, but if when the Log.d i put inside onClick like this :
Intent i = new Intent(DetailActivity.this, enlarge.class);
i.putExtra("IMAGEURL_KEY",touchimg);
startActivity(i);
if(touchimg != null)
Log.d("TAGput", "tidak null");
else
Log.d("TAGput", "image null");
the Log doesnt appear nothing, what is that mean?