how to check if an ImageView is attached with image in android

后端 未结 7 1475
半阙折子戏
半阙折子戏 2020-12-13 05:43

I am setting an image to ImageView in android code not in xml, but could not make out how to check whether that image has been set in or not in java.

Tried with

相关标签:
7条回答
  • 2020-12-13 06:37

    You can also do this when any drawable is in your imageview and after you are adding image from gallery or any where. Try This

    (imgAdd.drawable.constantState == resources.getDrawable(R.drawable.user_new).constantState) -> {
                        Snackbar.make(view, "Please Add Product Image",
                            Snackbar.LENGTH_SHORT).show()
                    }
    
    0 讨论(0)
提交回复
热议问题