手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >android中知道图片name时获取图片的简单方法
android中知道图片name时获取图片的简单方法
摘要:1.图片放在sdcard中,复制代码代码如下:BitmapimageBitmap=BitmapFactory.decodeFile(path...

1. 图片放在sdcard中,

复制代码 代码如下:

Bitmap imageBitmap = BitmapFactory.decodeFile(path) (path 是图片的路径,跟目录是/sdcard)

2. 图片在项目的res文件夹下面

复制代码 代码如下:

//得到application对象

ApplicationInfo appInfo = getApplicationInfo();

//得到该图片的id(name 是该图片的名字,"drawable" 是该图片存放的目录,appInfo.packageName是应用程序的包)

int resID = getResources().getIdentifier(name, "drawable", appInfo.packageName);

3. 图片放在src目录下

复制代码 代码如下:

String path = "com/timanetworks/jerome/activity/test.png"; //图片存放的路径

InputStream is = getClassLoader().getResourceAsStream(path); //得到图片流

【android中知道图片name时获取图片的简单方法】相关文章:

android实现字体闪烁动画的方法

Android 获取进程内存使用情况方法

Android加载图片内存溢出问题解决方法

Android开发之动画实现方法

android获取监听SD Card状态的方法

android 默认时间格式修改方法

android开发环境遇到adt无法启动的问题分析及解决方法

android异步加载图片并缓存到本地实现方法

Android如何实现非本地图片的点击态

android中实现指针滑动的动态效果方法

精品推荐
分类导航