开发者

how to refer to a Drawable object by an id of type in

开发者 https://www.devze.com 2023-03-31 07:29 出处:网络
From this page: public void setBackgroundResource (int resid) Se开发者_开发知识库t the background to a given resource. The resource should refer to a Drawable object or 0 to remove the background.

From this page:

public void setBackgroundResource (int resid)

Se开发者_开发知识库t the background to a given resource. The resource should refer to a Drawable object or 0 to remove the background.

So how do I refer to a Drawable object by an int id?


The common use case is

setBackgroundResource(R.drawable.mydrawable)

The R class contains an auto-generated int reference to each drawable resource in the project folder.

This has no use if you generate your Drawable in code or from any other source than the projects resources (that's why it's called setBackgroundRESOURCE()).

0

精彩评论

暂无评论...
验证码 换一张
取 消