//远程图片
public void httpBtnOnClick(View view) {

//网络图片URL
String path = "http://p4.so.qhimg.com/t0102672bd8a6bd290e.jpg";
imageView.setImageURI(Uri.parse(path));
}

//file本地SD卡图片加载
public void fileBtnOnClick(View view) {
//File资源加载
StringBuilder path = new StringBuilder("file://");
path.append(Environment.getExternalStorageDirectory());
path.append("/");
String fileName = "image.png";
path.append(fileName);
imageView.setImageURI(Uri.parse(path.toString()));
}

//assets目录下的资源
public void assetsBtnOnClick(View view) {
//assets资源加载
StringBuilder path = new StringBuilder("asset:///");
path.append("ic_launcher.png");
imageView.setImageURI(Uri.parse(path.toString()));
}

//res目录下的资源
public void resBtnOnClick(View view) {
//RES资源加载
StringBuilder path = new StringBuilder("res://");
//当前包名
path.append(this.getPackageName());
path.append("/");
//资源ID
path.append(String.valueOf(R.mipmap.a_0));//R.mipmap.a_0与R.drawable.a_0同样引用图片的资源ID
imageView.setImageURI(Uri.parse(path.toString()));
}
posted on 2015-08-29 17:35  蹭饭熊  阅读(390)  评论(0编辑  收藏  举报