how to get the source of ImageView in order to change it?

后端 未结 7 1857
醉话见心
醉话见心 2020-12-15 06:23

I know that changing the ImageView resource is not big deal just using myImageView.setImageResource(mynewImageDrawable)

but what I want to do is to chec

7条回答
  •  天涯浪人
    2020-12-15 06:33

    Are you saying that you intend to check the resource id to determine if a radio button is selected or not? While this could probably work, it isn't a very good design. Generally speaking you want to separate the model from the view (otherwise known as the Model-View-Controller paradigm). To do this, you might have your radio button group maintain an index for the selected item, and have each of your items stored in a list. When an item is selected, you can determine its index, update the group's model, and then update the UI to reflect that change.

    Its not that what you're proposing wont work, it just isn't good design and leads to poor maintainability (such as if the resource names change).

提交回复
热议问题