我怎么加上R绘制的Andr​​oid? [英] How do I add R drawable android?

查看:172
本文介绍了我怎么加上R绘制的Andr​​oid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Basicly我的问题是,如何添加一个可绘制资源android系统Eclipse中R.java文件,这样我可以用此code使用它:

Basicly my question is that how do I add a drawable resource to the R.java file in android eclipse so I can use it with this code:

ByteArrayOutputStream stream = new ByteArrayOutputStream();
        Bitmap bitmap = BitmapFactory.decodeResource(getBaseContext().getResources(),     R.drawable.kapschlogo);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100 , stream);
        Image myImg = Image.getInstance(stream.toByteArray());
        myImg.setAlignment(Image.MIDDLE);

        doc.add(myImg);

图片存储在父项目文件夹,但我不能弄清楚如何添加寿德R档。

The image is stored in the parent project folder but I cant figure out how do I add it tho te R file.

推荐答案

由于R.java文件会自动从你的资源产生你需要把图像文件(S)下的 RES /绘制文件夹,并从那里,他们将被索引并从 R.drawable.myImageFile (XML)或 getResources()。getDrawable(R.drawable访问。 myImageFile); (JAVA)

Since the R.java file is automatically generated from your resources you need to put the image file(s) under the res/drawable folder and from there they will be indexed and accessible from R.drawable.myImageFile(XML) or getResources().getDrawable(R.drawable.myImageFile);(java)

这篇关于我怎么加上R绘制的Andr​​oid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆