я думаю, что вам нужно здесь код является один
mydialog.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="wrap_content"
android:orientation="vertical" >
<Button
android:id="@+id/ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ok"
android:layout_gravity="center"
/>
</LinearLayout>
.
Dialog dialog=new Dialog(mContext);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.mydialog);
dialog.getWindow().getAttributes().width = LayoutParams.FILL_PARENT;
dialog.getWindow().setBackgroundDrawableResource(R.drawable.dialogbackground);
Button mOkButton=(Button)dialog.findViewById(R.id.ok);
mOkButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//do here what you want to do with ok button click
}
});
Здесь dialogbackground
является фоновым изображением
Добавить компоненты ваш XML-файл. –
@ user972890 следуйте по этому адресу http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235 – Akram