This is not an answer, but for others who check this question, instanceof does not work in some cases (I donβt know why!), For example, if you want to check if the view type is ImageView or ImageButton (I tested this situation), they will get they are the same, so you scan it like this:
//v is your View if (v.getClass().getName().equalsIgnoreCase("android.widget.ImageView")) { Log.e("imgview", v.toString()); imgview = (ImageView) v; } else if (v.getClass().getName().equalsIgnoreCase("android.widget.ImageButton")) { Log.e("imgbtn", v.toString()); imgbtn = (ImageButton) v; }
Arash
source share