I want to check which image resource is attached to ImageView
in xml, I am able to check that which image resource is attached to image view but my requirement
You can do something like following,
Set a tag
either through xml or dynamically as per your requirement.
Through xml,
Dynamically,
ImageView imageView=(ImageView)findViewById(R.id.imageview1);
imageView.setTag("bg");
Use imageView.getTag()
to retrieve image information.
String backgroundImageName = String.valueOf(imageView.getTag());
Edit:
if you are changing ImageView
background frequently then,
imageView.setTag(R.drawable.drawablename);
imageView.setImageResource(R.drawable.drawablename);
String backgroundImageName = String.valueOf(imageView.getTag());
Now you can make your check.
if (backgroundImageName.equals("bg")) // here "bg" is the tag that you set previously
{
Toast.makeText(_con, "Image is ivPic", Toast.LENGTH_LONG).show();
// new RegisterAsyntaskNew().execute();
}
else
{
Toast.makeText(_con, "Image isn't ivPic", Toast.LENGTH_LONG).show();
// new RegisterAsyntask().execute();
}