java - Glide 不适用于我

标签 java android android-glide

我不知道为什么 glide 对我不起作用 我是这样说的:

 Glide.with(this)
            .load("http://api.androidhive.info/images/glide/medium/deadpool.jpg")
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .crossFade()
            .skipMemoryCache(true)
            .into(imgheader);

我也将此添加到我的 gradle 中:

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

还有互联网许可, 我也尝试毕加索,但同样,不起作用!

我该怎么办

我在 fragment 和 Activity 中使用它,同样的问题

  protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.open_new);
    toolbarLayout= (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
    imgheader= (ImageView) findViewById(R.id.imageheader);
    titleView=(TextView)findViewById(R.id.title);
    infoView=(TextView)findViewById(R.id.info);

    Intent intent = getIntent();
    title =intent.getStringExtra("title");
    date =intent.getStringExtra("date");
    info =intent.getStringExtra("info");
    imgurl =intent.getStringExtra("imgurl");
    id =intent.getIntExtra("id",0);
    show =intent.getStringExtra("show");
    Toast.makeText(this,imgurl,Toast.LENGTH_LONG).show();
    Glide.with(this)
            .load(Uri.parse(imgurl))
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .crossFade()
            .error(R.drawable.desktop)
            .skipMemoryCache(true)
            .into(imgheader);
    imgheader.setVisibility(View.VISIBLE);
    titleView.setText(title);
    infoView.setText(info);

在我的 xml 中我有这个:

 <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/toolbar_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="192dp"
            android:scaleType="centerCrop"
            app:layout_collapseMode="parallax"
            android:adjustViewBounds="false"
            android:id="@+id/imageheader"
            android:src="@drawable/imgtest"
            android:textColor="#ffffff" />
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    </android.support.design.widget.CollapsingToolbarLayout>

最佳答案

是我的错 正确用法:

<uses-permission android:name="android.permission.INTERNET"/>

但我用过:

<permission  android:name="android.permission.INTERNET"></permission>

关于java - Glide 不适用于我,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37981251/

相关文章:

java - 如何重新运行JavaFX应用程序

java - 无法从代码向 XML 布局添加 View

java - 错误代码或异常 : How to communicate errors from model to controller in my case?

java - 你可以采取哪些步骤来使带有 setter 的 java 对象不可变?

java - 如何在 android 中使用 DateFormat.getDateTimeInstance() 仅显示当前时间

java - 我的 json 代码工作正常,但是当添加 Glide 来解析图像时应用程序强制停止

android - 在 android 通知中显示带 Glide 的 GIF

android - 是否可以使用 Glide 来缓存非图像文件,例如视频和 Lottie 动画?

android - 在 Android 上录制视频时拍照

android - 程序类型已经存在 : com. google.common.util.concurrent.ListenableFuture Duplicate Class