Hello every one I am new in the android studio I have a picture in my drawable folder and I want it to save the picture as a background of the edit text programmatically for this I write a code bellow but its not working and it showing a red line error
here is my code.
edit_text.setBackground(R.drawable.background1);
any idea for this how I will write it please don't suggest me another post as I am new here.
CodePudding user response:
You should retrieve the background drawable using ContextCompat.getDrawable
method:
edit_text.setBackground(ContextCompat.getDrawable(this, R.drawable.background1));