1.添加依赖:compile 'org.xutils:xutils:3.5.0'
2.清单文件中注册初始化 初始化:x.Ext.init(this); x.Ext.setDebug(BuildConfig.DEBUG); // 是否输出debug日志, 开启debug会影响性能.//上线后参数设为false 将debug关掉
3.使用utils3加载网络图片 x.image().bind(image, "https://p.ssl.qhimg.com/t01d15b1004b11cb0a7.jpg");
4.使用utils3加载本地动态图片 1)创建assets文件 存放动态图片 2)ImageOptions imageOptions = new ImageOptions.Builder() .setIgnoreGif(false) .setImageScaleType(ImageView.ScaleType.CENTER).build(); x.image().bind(image, "assets://d.gif", imageOptions);
5.使用utils3加载网络数据 RequestParams requestParams=new RequestParams("http://apicloud.mob.com/v1/cook/category/query?key=1d11949556a24"); x.http().get(requestParams, new Callback.CommonCallback<String>() { @Override public void onSuccess(String result) { Log.d("sss","onSuccess::"+result); } @Override public void onError(Throwable ex, boolean isOnCallback) { Log.d("sss","onError::"+ex.getMessage()); } @Override public void onCancelled(CancelledException cex) { Log.d("sss","onCancelled::"+cex.getMessage()); } @Override public void onFinished() { Log.d("sss","onFinished::"); } });