package gongzibai.co.cc;
import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
public class ProgressBarActivity extends
Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(
Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Dialog dialog = new Dialog(this);
dialog.setTitle("loveyou");
//对话框设置 视图,新建一个布局main1
dialog.setContentView(R.layout.main1);
//触屏对话框以外区域,对话框消失
dialog.setCanceledOnTouchOutside(true);
dialog.show();
}
}
-----------------AlertDialog
final DialogInterface.OnClickListener closeDialog = new
DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialog,
int which) {
// TODO Auto-generated method stub
dialog.cancel();
}
};
-------------AlertDialog属性
AlertDialog.Builder builder = new AlertDialog.Builder(
ProgressBarActivity.this);
builder.setIcon(R.drawable.ic_launcher);
builder.setTitle("loveyou");
builder.setMessage("great to see you");
builder.setNegativeButton(
"NO",
closeDialog);
builder.setPositiveButton(
"ok",
closeDialog);
builder.setNeutralButton(
"取消",
closeDialog);
builder.create()
.show();