How do you obtain a Drawable object from a resource id in android package?
问题 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.* package? for example if drawableId was android.R.drawable.ic_delete mContext.getResources().getDrawable(drawableId) 回答1: Drawable d = getResources().getDrawable(android.R.drawable.ic_dialog_email); ImageView image = (ImageView)findViewById(R.id.image); image.setImageDrawable(d); 回答2: As of API 21 , you should use the