我怎么加上R绘制的Android? [英] How do I add R drawable android?
问题描述
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绘制的Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!