所以我正在展示类似于这样的AlertDialog:
new AlertDialog.Builder(context)
.setMessage(message)
.setTitle(title)
.setCancelable(true)
.setIcon(R.drawable.ic_launcher) // set icon
// more code
是否可能使用setIcon
方法从数据库中获取图标,例如联系人照片?
DatabaseHelper db = new DatabaseHelper(context);
Cursor csr = db.getSpecialContact(number);
csr.moveToFirst();
String photo = csr.getString(csr.getColumnIndexOrThrow("photo_url"));
Uri photo_url = Uri.parse(photo);
我希望能够使用photo_url
(保存在数据库中,如content://com.android.contacts/data/1
)并将其与setIcon
一起使用,但当然它期望参数是int
而不是string
或Uri
。请问这可以实现吗?
BitmapDrawable
结合使用?您能否更详细地说明一下您的示例?谢谢。我认为构造函数BitmapDrawable
不支持参数。 - Dev01