How to display an image in Dialog using Glide? - java

in my app there is an dialog with an image on it.
How can I display an image using glide?
Here is what I tried in my Fragment:
RequestOptions options = new RequestOptions()
.centerCrop()
.placeholder(R.drawable.goldversiondialog)
.error(R.drawable.goldversiondialog);
Glide.with(getActivity()).load(myURL).apply(options).into(goldimageview);
It is not working, it only displays the error image.
I also don't know what to write as context, "this" is not working in fragments.
How can I solve this?

Related

Loading an image inside a bottom navigation bar item icon using an URL

I'm trying to load a profile image using the firebase storage url inside an item's icon of a bottom navigation bar, here's my code:
Glide.with(getApplicationContext()).asBitmap().load(profilePicUrl)
.into(new CustomTarget<Bitmap>() {
#Override
public void onResourceReady(#NonNull Bitmap resource, #Nullable Transition<? super Bitmap> transition) {
Drawable profileImage = new BitmapDrawable(getResources(), resource);
bottomNav.getMenu().getItem(4).setIcon(profileImage);
}
#Override
public void onLoadCleared(#Nullable Drawable placeholder) {
}
});
The profilePicUrl does work, I already use it to for another image view. However when I run the app, the dimensions of the icon changes corresponding to the picture that I'm trying to load but there's no image inside, here's how it looks.
Menus do not support coloured images
You can not use a coloured image in these places and a bit more also:
In bottom navigation
In navigation drawer
In popup menu
etc...
Basically which ever view uses a menu file for its resource, cannot have a coloured image. That is why you don't see it. To test it yourself, take a colourful image in your drawable and set it as an icon for the bottom navigation. You notice that it comes the same way. This proves it
Edits
This post gives some info on how to do it
You can do it this way:
mBottomNav.setItemIconTintList(null);

how to get background image in android (java)

I want to get background image of Home screen programmatically in Android and set it to background in my activity in my App.
How can i get background image? please guide me.
like this
final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
final Drawable wallpaperDrawable = wallpaperManager.getDrawable();
use the drawable the way you want

In Android Studio How to make Validation for imageview?

How to make validation in android studio for image view.
E.g. I have button when i click on button it open a gallery and i select image it comes in image view but how to set that if someone not upload image it will show message till not upload image in image view
Thanks.
The uri or bitmap that you use to save the image, use it in sharedPreferences. So that when the default value is null user will get the message but when you add a new image it will overwrite the default value of sharedPreferences and hide the messgae.

Loading an image from assets and displaying in a dialog

I have a lot of images in the assets folder of my application that I'd like to display in a dialog popup. How can I go about doing this? I saw a similar question covering how to display the icons, with a pretty solid answer. But in the answer, the icons are pulled from a drawable. So, I suppose I have two options:
I have taken a look at the "Icons in a list dialog" thread but the answer posted uses drawables. I don't have a drawable for every single image because I have over 250 images.
Then I saw the "load drawable from assets" thread, but that doesn't quite get me there either. The "icons in a list dialog" expects a specific r.drawable.drawablename.
This is currently how I display the countries text:
public void onClick(Card card, View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(FtC_Setup.this);
builder.setTitle("Standard countries");
final CharSequence[] items = FtC_Play.allCountries.toArray(new CharSequence[FtC_Play.allCountries.size()]);
builder.setItems(items, null).show();
}

gallery view on android in alertdialog

I have source code for a slider puzzle. it delivers a random image for the puzzle and you can change alot of settings like tiles and numbers and what not. Its really easy to add pictures you just have to have them start with image_ and put them in the drawable folder. Only thing is it does not have a layout.xml i guess everything is written through the activity.
I want to have all of the pictures in like a gallery view when a button is clicked in the menu. i have seen all the gallery codes need code in the layout which this source code does not have so essentially i would like
rather than this
public void showAbout()
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.title_about);
builder.setMessage(R.string.content_about);
builder.setPositiveButton(R.string.label_ok, null);
builder.setIcon(R.drawable.ic_launcher);
AlertDialog dlg = builder.create();
dlg.show();
((TextView) dlg.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
}
i just want it to show up as a photo gallery

Categories

Resources