Android Onclick Method Want Image Path
I display image from the web in my application. It is running perfectly My Question is : what is method,function to take current image URL when I click on image.? (I passed url as
Solution 1:
Simply what you can do is
loadImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
imgUrl = getAnImageUrl();
image.setImageDrawable(imgUrl);
}
});
image.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), imgUrl+ " this one", Toast.LENGTH_LONG).show();
// TODO Auto-generated method stub
}
Or you can also User setTag(Object object); method of view e.g
loadImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String url = getAnImageUrl();
image.setImageDrawable(url);
image.setTag(url);
}
});
image.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), image.getTag()+ " this one", Toast.LENGTH_LONG).show();
// TODO Auto-generated method stub
}
And If you still have problem that image is not change. Then Please share your code of LoaderImageView.java as the image request , update is handled in that.
Post a Comment for "Android Onclick Method Want Image Path"