问题
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