How to pass a Drawable_icon to backend code?

36 views Asked by At
  • I want to access a default icon (cross) in Android Studio itself, called ic_delete, in the definition section of deleteButton in the code below. But I don't know how to pass it to my backend code. When I use the following code to call it, I get an error and the code does not recognize it. deleteButton.setImageResource(R.drawable.ic_delete)

  • The second problem is, how should I set textParams.gravity so that the entered text is placed exactly in the centre of the TextView (both horizontally and vertically)? [part1 of the code]

part2

I tried this code but it doesn't work.

deleteButton.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_delete))
0

There are 0 answers