UIL默认不支持scheme(protocol) [英] UIL doesn't support scheme(protocol) by default
问题描述
我在控制台中收到此错误.
I am getting this error in my console.
UIL doesn't support scheme(protocol) by default ["http://mywebsite.com/mylocation/image.jpg"]. You should implement this support yourself (BaseImageDownloader.getStreamFromOtherSource(...))
我正在尝试将网站中的图像加载到android应用程序中.遵循的步骤:在build.gradle
I am trying to load images from my website into an android application. Steps followed: In build.gradle
dependencies {compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'}
在AndroidManifest.xml
In AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
这是我得到的json输出:
This is the json output I am getting:
"image":"\"http:\\\/\\\/mywebsite.com\\\/mylocation\\\/image.jpg\""
在我的ApplicationActivity.java
In my ApplicationActivity.java
ImageView myImage
myImage = (ImageView)findViewById(R.id.image_id);
我尝试剥离所有不必要参数的网址,如下所示:
I tried stripping the url of all unnecessary parameters as below:
imageUrl = url.replaceAll("\\[]\"", "");
imageUrl = imageUrl.replace("\\/","/");
这是ApplicationActivity.java中的代码,我曾尝试使用UniversalImageLoader加载图像:
This is the code in ApplicationActivity.java that I used to try and load the image using UniversalImageLoader:
DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
.cacheInMemory(true)
.cacheOnDisk(true)
.build();
//
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
.defaultDisplayImageOptions(defaultOptions)
.build();
ImageLoader.getInstance().init(config);
Toast.makeText(single_event.this, imageUrl, Toast.LENGTH_LONG).show();
if(imageUrl != null) {
//Sets Image
ImageLoader.getInstance().displayImage(imageUrl, myImage);
}
Log.d("URL", imageUrl);
控制台日志和祝酒词均返回引号中正确的网址" http://mywebsite.com/mylocation/image.jpg "
The console log and the toast both return the correct url in quotes "http://mywebsite.com/mylocation/image.jpg"
我错过了一些配置或设置吗?在 ImageLoader.getInstance().displayImage(imageUrl,myImage);之后,我还有什么需要做的?
?
Is there some configuration or setup i have missed?
Is there anything extra I hould do after ImageLoader.getInstance().displayImage(imageUrl, myImage);
?
请协助.
这是布局(下).如果我在布局中将图像源指定为可绘制图像,则从手机加载图像,所有Java逻辑都将被忽略.如果我删除了源,那么什么也没发生< ImageViewandroid:layout_width ="fill_parent"android:layout_height ="120dp"android:id ="@ + id/image_id"android:layout_marginTop ="3dp"android:layout_marginBottom ="3dp"android:contentDescription ="@ string/cnt"android:src ="@ drawable/local_placeholder"/>
This is the layout (below). If I specify the image source in the layout to be an image in drawable, then the image is loaded from the phone and all the java logic is ignored. If I remove the source, then nothing happens
<ImageView
android:layout_width="fill_parent"
android:layout_height="120dp"
android:id="@+id/image_id"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:contentDescription="@string/cnt"
android:src="@drawable/local_placeholder"
/>
推荐答案
imageUrl = imageUrl.substring(1, imageUrl.length()-1);
从" http://mywebsite.com/mylocation/image.jpg"解决了问题.
这篇关于UIL默认不支持scheme(protocol)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!