【发布时间】:2021-02-26 14:08:37
【问题描述】:
代码:
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
image_person = (ImageView) findViewById(R.id.dialog_imageview);
}
public void checkBox_checker(String checkerID, String checkerName, String checkerSurname, String
checkerDescription, Blob picture) throws SQLException
{
int blobLength = (int) picture.length();
byte[] bytes = picture.getBytes(1,blobLength);
Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
Log.d(TAG, "Checker box");
LayoutInflater factory = LayoutInflater.from(MainActivity.this);
final View alertDialog= factory.inflate(R.layout.sample, null);
image_person.setImageBitmap(bitmap);
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setCancelable(true);
builder.setView(alertDialog);
builder.setTitle("Information");
builder.setMessage(message);
builder.setNegativeButton("Report", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
builder.setPositiveButton("Enter", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
builder.show();
}
Sample.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
<ImageView
android:id="@+id/dialog_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
我的问题是图像被插入到警报对话框的后面,而不是在警报对话框内。有人可以帮助我了解为什么会这样吗?
我在 xml 文件中输入了图像,它确实显示在警报对话框中。所以不太清楚为什么会这样。
【问题讨论】:
标签: android bitmap imageview android-alertdialog