package com.example.uiwidgettest2; import android.app.Activity;import android.app.AlertDialog;import android.content.DialogInterface;import android.os.Bundle;import android.view.View;import android.widget.*; public class AlertDialogActivity extends Activity{ private ProgressBar progressBar = null; private Button btn1 = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.edittext); progressBar = (ProgressBar)findViewById(R.id.progress_bar); btn1 = (Button)findViewById(R.id.button1); btn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder dialog = new AlertDialog.Builder(AlertDialogActivity.this);
dialog.setTitle("警告框"); dialog.setMessage("内容"); dialog.setCancelable(false); dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dialog.show(); } }); }
时间: 2024-10-26 04:40:10