Android 开发小计

获取资源文件中的图像(Bitmap)

在中项目文资源文件中有这么一个图像文件(/res/drawable/icon.jpg),获取此文件的Bitmap:

 Bitmap pBitmap=Context.BitmapFactory.decodeResource(getResources(), R.drawable.abc);

获取在资源文件中的字符串

在res/values/string.xml中有这么一个定义:

<string name="app_name">Compass</string>

 在代码中显示内容:

Context.getString(R.string.app_name);

原文地址:https://www.cnblogs.com/wservices/p/1732612.html