Macya
V2EX  ›  Android

Glide 使用 SimpleTarget 加载网络图片

  •  
  •   Macya · Apr 18, 2016 · 19559 views
    This topic created in 3853 days ago, the information mentioned may be changed or developed.

    最近在学习 Glide ,在使用 SimpleTarget 的时候, Android Studio 给出了这样一个警告

    Unchecked method 'into(Y)' invocation

    实际运行是没问题的 但是这个警告是什么意思呢?

    代码:

    Glide.with(getApplicationContext())
        .load(internetUrl)
        .error(R.mipmap.ic_launcher)
        .into(simpleTarget);
        
    simpleTarget = new SimpleTarget<Drawable>(){
    	@Override
    	public void onResourceReady(Drawable resource, GlideAnimation<? super Drawable> glideAnimation) {
    		imageView_top.setImageDrawable(resource);
    	}
    };
    
    2 replies  •  2016-04-19 09:37:57 +08:00
    EdiTurn
    EdiTurn
    Apr 19, 2016
    1
    into 接收的参数是 Y extends Target<TranscodeType>,猜测你 simpleTarget 的声明没有指定泛型。

    另,在本例中, TranscodeType 需要是 GldieDrawable (见 load 的返回类型)。
    Macya
    Macya
    OP
    Apr 19, 2016
    2
    @EdiTurn simpleTarget 的声明确实没有指定泛型,这个案例是按照某个翻译的 blog 对着做的,没有想到这点,加上泛型之后,警告消失了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4817 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 08:20 · PVG 16:20 · LAX 00:20 · JFK 03:20
    ♥ Do have faith in what you're doing.