i think you need code here is the one
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 } });
Here dialogbackground is the background image