Found Drawable, Required 'int'. I am trying to load image in gravityView by Glide library

房东的猫 提交于 2021-01-29 14:58:56

问题


I am trying to load images from url with the help of glide library in gravityView. I searched many solutions and came up with this solution, but this code is giving me the error - Found Drawable, Required 'int'.

public class gravity_view extends AppCompatActivity {

    public String imgurl;
    ImageView img;
    GravityView gravityView;

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

        img = findViewById(R.id.bg); <--- This is my image holder where i want to show image

        Intent callingActivityIntent = getIntent();

        if (callingActivityIntent != null) {
            imgurl = callingActivityIntent.getStringExtra("image"); <-- getting image url from another activty.
            if (imgurl != null && img != null) {

                Glide.with(getApplicationContext()).load(imgurl).into(new CustomTarget<Drawable>() {
                    @Override
                    public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
                        gravityView.setImage(img, resource).center(); <--- Getting the error.
                    }

                    @Override
                    public void onLoadCleared(@Nullable Drawable placeholder) {

                    }
                })
            }
        }


    }

    @Override
    protected void onResume() {
        super.onResume();
        gravityView.registerListener();
    }

    @Override
    protected void onStop() {
        super.onStop();
        gravityView.unRegisterListener();
    }

}

Please help me out. I have searched thousands of time but did not got any solutions.

来源:https://stackoverflow.com/questions/63971366/found-drawable-required-int-i-am-trying-to-load-image-in-gravityview-by-glid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!