How to check which current image resource is attached to ImageView in android xml?

前端 未结 6 713
说谎
说谎 2020-12-05 01:48

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

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 02:23

    I already answered on the similar topic here: Get the ID of a drawable in ImageView. The approach is based on tagging a view with a specified resource id in the custom LayoutInflater. Whole process is automated by a simple library TagView.

    As a result, you can compare two drawables just by their ids:

    TagViewUtils.getTag(regProfile, ViewTag.IMAGEVIEW_SRC.id) == R.drawable.ivpic
    

提交回复
热议问题