简体   繁体   English

Android-AlertDialog将不会显示BitmapDrawable

[英]Android - AlertDialog won't show BitmapDrawable

In my app, I'm downloading a small Facebook profile picture and show it in an AlertDialog (as BitmapDrawable ) along with the user first and last name. 在我的应用程序中,我正在下载一个小的Facebook个人资料图片,并将其与用户的名字和姓氏一起显示在AlertDialog (作为BitmapDrawable )。

Now, my problem is that on some devices the BitmapDrawable is shown in the AlertDialog (Android ~4.0) and on some it isn't (5.0 and above), but in all the devices the BitmapDrawable contains the right bitmap and I'm able to load that BitmapDrawable to an ImageView for example. 现在,我的问题是,在某些设备上, BitmapDrawable显示在AlertDialogAlertDialog )中,而在某些设备上却没有显示(5.0及更高版本),但是在所有设备上, BitmapDrawable包含正确的位图,并且我能够例如, BitmapDrawable加载到ImageView

((ImageView)findViewById(R.id.imageView3)).setImageDrawable(bitmapDrawable); //Shown in the ImageView on all devices

AlertDialog ad = new AlertDialog.Builder(MainActivity.this)
                        .setTitle("From: " + name + " " + lastName)
                        .setMessage(theStr)
                        .setNeutralButton(theStr2, new myClick(marker, thePack))
                        .setIcon(bitmapDrawable)  //Not shown in the AlertDialog on all devices
                        .show();

Any idea? 任何想法?

UPDATE: Even in the debugger I can see the icon set in the AlertDialog and the debugger also allow me to view the bitmap of it and it's shown perfectly. 更新:即使在调试器中,我也可以在AlertDialog看到图标集,并且调试器还允许我查看其位图,并且它的显示效果完美。 It's just won't show up in the dialog and I don't know why. 它只是不会显示在对话框中,我也不知道为什么。

  1. Try setting a drawable from the resource just to see if that works. 尝试从资源中设置一个可绘制对象,看看是否可行。

  2. If I'm not wrong try changing the default app theme (It's weird but for me it worked in some special cases). 如果我没看错,请尝试更改默认的应用程序主题(这很奇怪,但对我来说在某些特殊情况下有效)。

Also I've found this bug report while searching, 另外,我在搜索时发现了此错误报告,

https://code.google.com/p/android/issues/detail?id=92929 https://code.google.com/p/android/issues/detail?id=92929

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM