基本上我的问题是如何将可绘制资源添加到 android eclipse 中的 R.java 文件,以便我可以将其与此代码一起使用:
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 文件中。
最佳答案
由于 R.java 文件是从您的资源中自动生成的,您需要将图像文件放在 res/drawable 文件夹下,它们将从那里被索引并可从 R.drawable.myImageFile
(XML) 或 getResources().getDrawable(R.drawable.myImageFile);
(java)
关于android - 如何添加 R drawable android?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17980621/