我需要一个 Drawable 对象以显示在图像按钮上。有没有办法使用下面的代码(或类似的代码)从 android.R.drawable.* 包中获取对象?
例如,如果 drawableId 是 android.R.drawable.ic_delete
mContext.getResources().getDrawable(drawableId)
最佳答案
Drawable d = getResources().getDrawable(android.R.drawable.ic_dialog_email);
ImageView image = (ImageView)findViewById(R.id.image);
image.setImageDrawable(d);
关于android - 如何从 android 包中的资源 id 获取 Drawable 对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7815689/