试试这个:
final Dialog commentDialog = new Dialog(this);
commentDialog.setContentView(R.layout.reply);
Button okBtn = (Button) commentDialog.findViewById(R.id.ok);
okBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//do anything you want here before close the dialog
commentDialog.dismiss();
}
});
Button cancelBtn = (Button) commentDialog.findViewById(R.id.cancel);
cancelBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
commentDialog.dismiss();
}
});
reply.xml
android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffff">
android:layout_gravity="center" android:layout_height="wrap_content"
android:hint="@string/your_comment" android:id="@+id/body" android:textColor="#000000"
android:lines="3" />
android:layout_height="fill_parent">
android:layout_width="wrap_content" android:text="@string/send" android:layout_weight="1"
/>
android:layout_width="wrap_content" android:layout_weight="1"
android:text="@android:string/cancel" />