Change xml selector values from java code

前端 未结 2 2071
清歌不尽
清歌不尽 2020-12-16 06:16

I am trying to create a universal image selector for multiple buttons. Is there an option to change the xml\'s \"android:drawable\" resource from java code?

2条回答
  •  感动是毒
    2020-12-16 06:49

    You can set button drawable from java like

        btnSettings.setBackgroundResource(R.drawable.ic_launcher);
    

提交回复
热议问题