2017-02-07 52 views
0

我有簡單的佈局與ImageView的滑翔無法加載圖像

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.vbusovikov.glidetest.MainActivity"> 

    <ImageView 
     android:id="@+id/image" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     /> 

</RelativeLayout> 

而簡單滑翔表達將圖像加載到這個ImageView的只是爲了測試滑翔

@Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     ImageView imageView = (ImageView)findViewById(R.id.image); 

     Glide.with(this) 
       .load("http://you-ps.ru/uploads/posts/2013-08/1376601606_1273.png") 
       .error(R.mipmap.ic_launcher) 
       .into(imageView); 

    } 

然而,示出了錯誤圖標。 它可能是什麼樣的問題? 我在我的網絡上有代理服務器,並且適合這種情況的gradle.properties。

systemProp.http.proxyHost=proxy******.ru 
systemProp.http.proxyPort=**** 

但即使我嘗試在任何代理之外啓動這個小應用程序,但由於某種原因它將不起作用。

我的build.gradle文件

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.2" 
    defaultConfig { 
     applicationId "com.example.vbusovikov.glidetest" 
     minSdkVersion 15 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:25.1.1' 

    compile 'com.github.bumptech.glide:glide:3.7.0' 

    testCompile 'junit:junit:4.12' 
} 

UPD。這個簡單的應用程序可以從互聯網上載入圖片,但無法從我的服務器載入圖片。我的服務器的一些圖片加載正常,但其他人沒有。我失去了我的side..check網絡這個已經

+0

'嘗試在任何代理之外啓動這個小應用程序,它不會因爲某種原因而工作,請嘗試更改圖像。它工作與否? –

+1

'Glide.with(yourclass.this)' –

+0

http://stackoverflow.com/questions/36384789/glide-not-loading-real-image-and-stuck-with-placeholder –

回答

0

可惜的是,所有的答案是正確的,但在我的條件不工作。服務器設置不適合從它下載圖片。

0

它工作正常,不忘記添加Internet權限清單中。:)

+0

我有這個權限 – TrueCH

+0

你可以在這裏粘貼你的build gradle和logcat :) –

+0

在這裏找到我的答案,https://stackoverflow.com/a/45108669/1068800 – Neela

0

嘗試添加標籤的佔位符太(看起來奇怪,但這個固定我就在我身邊)

Glide.with(YourActivity.this) 
       .load("http://you-ps.ru/uploads/posts/2013-08/1376601606_1273.png") 
       .error(R.mipmap.ic_launcher) 
       .placeholder(R.mipmap.placeholder) 
       .into(imageView); 
+0

不工作,我也試過'dontAnimate()',它沒有工作 – TrueCH

+0

在這裏找到我的答案,https://stackoverflow.com/a/45108669/1068800 – Neela