Set a drawable as background programmatically

前端 未结 3 684
一整个雨季
一整个雨季 2021-02-07 09:32

EDIT: Sorry I realise from your comment my question was not clear enough. I will post a new one. Sorry for this and thanks for your answers

I am populat

3条回答
  •  无人及你
    2021-02-07 09:48

    Try this

    iv.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.img));
    

    or

    iv.setBackgroundResource(R.drawable.img);
    

提交回复
热议问题