How do you obtain a Drawable object from a resource id in android package?

前端 未结 6 981
别跟我提以往
别跟我提以往 2020-12-12 15:18

I need to get a Drawable object to display on an image button. Is there a way to use the code below (or something like it) to get an object from the android.R.drawable.* pac

6条回答
  •  自闭症患者
    2020-12-12 15:56

    Drawable d = getResources().getDrawable(android.R.drawable.ic_dialog_email);
    ImageView image = (ImageView)findViewById(R.id.image);
    image.setImageDrawable(d);
    

提交回复
热议问题