2

I wrote an android library for some UI utilities. I have a function that return ImageView. But, my problem is that I want that the resource of the drawable image, will be in the project that contains the library. I will explain...

I want that the ImageView will always take the drawable with the source name: R.drawable.ic_img_logo (and only this name). This resource will not actually be in the library. But the project that contains the library will contains also drawable with the resource name R.drawable.ic_img_logo.

I know that this thing works with id (of views), you can create file call ids.xml and define some ids in the file that others can use them, and you will recognize them.
But how can I do this with drawables?

4

3 に答える 3

0

ドローアブルがライブラリにない場合、それはリソースではありません。

別の方法は、次のようにアセットからアクセスすることです。

Drawable d = Drawable.createFromStream(getAssets().open(path_in_assets), null);

は定数path_in_assetsになります。

于 2013-06-28T21:49:54.640 に答える