Create one sample.xml
and add ImageView
in that XML.
sample.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/dialog_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>
Java Code :
AlertDialog.Builder alertadd = new AlertDialog.Builder(MessageDemo.this);
LayoutInflater factory = LayoutInflater.from(MessageDemo.this);
final View view = factory.inflate(R.layout.sample, null);
alertadd.setView(view);
alertadd.setNeutralButton("Here!", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dlg, int sumthin) {
}
});
alertadd.show();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…