当前位置:操作系统 > 安卓/Android >>

Android AlertDialog 对话框添加、属性

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 DialogInte易做图ce.OnClickListener closeDialog = new

DialogInte易做图ce.OnClickListener() {

   @Override
   public void onClick(
     DialogInte易做图ce dialog,
     int which) {
    // TODO Auto-generated method stub
    dialog.cancel();

   }
  };

-------------AlertDialog属性   www.zzzyk.com
 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();


 

作者:gongzibai
补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,