您的位置:首页 > 移动开发 > Android开发

Android getResources()方法

2016-05-04 16:45 501 查看
Android 中利用getResourses()方法获取各种资源。然后可以用openRawResource方法(不带后缀的资源文件名)打开某个文件。

Resources myResources = getResources();
InputStream myFile = myResources.openRawResource(R.raw.myfilename);
Resources myResources = getResources();
InputStream myFile = myResources.openRawResource(R.raw.myfilename);


例如,打开res.drawable中的图像文件:

Drawable currentIcon = null;
currentIcon = getResources().getDrawable(R.drawable.image);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: