对话框的代码android,android开发进程1----对话框源代码

package com.jerry;

import android.app.AlertDialog;

import android.app.ProgressDialog;

import android.content.DialogInterface;

import android.os.Bundle;

import android.util.Log;

import android.view.LayoutInflater;

import android.view.View;

public class Jerry_Dialog extends JerryActivity

{

ProgressDialog m_Dialog;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);

setContentView(R.layout.jerry_dialog_bg);

// jin

AlertDialog.Builder outbuilder = new AlertDialog.Builder(Jerry_Dialog.this);

outbuilder.setTitle("登陆提示");

outbuilder.setMessage("这里需要登录!");

outbuilder.setPositiveButton("确定", new DialogInterface.OnClickListener()

{

public void onClick(DialogInterface dialog, int which)

{

// TODO Auto-generated method stub

Log.v("jin", "确定按钮");

LayoutInflater factory = LayoutInflater.from(Jerry_Dialog.this);

final View DialogView = factory.inflate(R.layout.jerry_dialog_bg, null);// 得到自定义对话框

AlertDialog.Builder innerBuilder = new AlertDialog.Builder(Jerry_Dialog.this);

innerBuilder.setTitle("登陆中....jerry.");

innerBuilder.setView(DialogView);// 设置自定义对话框的样式

innerBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener()

{

public void onClick(DialogInterface dialog, int which)

{

// TODO Auto-generated method stub

//Log.v("jin", "--------not here--");

//m_Dialog = ProgressDialog.show(Jerry_Dialog.this, "请等等", "正在为你登陆。。。", true);

//new Thread()

//{

//public void run()

//{

//try

//{

//sleep(10000);

//} catch (Exception e)

//{

TODO: handle exception

//}

//finally{

登陆结束,取消对话框

m_Dialog.dismiss();

//}

//}

//}.start();

//

//testSingle();

testMukti();

/

}

});

//老是显示不出来,没有写这两句话

AlertDialog innerAlertDialog=innerBuilder.create();

innerAlertDialog.show();

}

});

outbuilder.setNegativeButton("取消", new DialogInterface.OnClickListener()

{

public void onClick(DialogInterface dialog, int which)

{

// 点击"取消"按钮之后退出jerry_dialog

Jerry_Dialog.this.finish();

}

});

outbuilder.setNeutralButton("退出", new DialogInterface.OnClickListener()

{

public void onClick(DialogInterface dialog, int which)

{

// TODO Auto-generated method stub

Jerry_Dialog.this.finish();

}

});

AlertDialog dialog = outbuilder.create();

dialog.show();

}

@Override

public String getName()

{

// TODO Auto-generated method stub

return null;

}

AlertDialog alertDialog;

/**

* 测试单选

*/

private void testSingle(){

AlertDialog.Builder builder00=new AlertDialog.Builder(this);

builder00.setTitle("jerry test");

//setMessage和setSingleChoiceItems不能并列使用

//builder00.setMessage("android dialog test");

builder00.setSingleChoiceItems(new String[]{"aa","bb","cc","dd","ee","ff"}, 0, new DialogInterface.OnClickListener()

{

//which 是单选的索引

//question dialog 这个参数如何获取?

public void onClick(DialogInterface dialog, int which)

{

// TODO Auto-generated method stub

if(dialog.equals(alertDialog)){

Log.v("jin", "=================");

}

Log.v("jin", "which="+which);

}

});

AlertDialog alertDialog=builder00.create();

alertDialog.show();

}

public void testMukti(){

AlertDialog.Builder builder00=new AlertDialog.Builder(this);

builder00.setTitle("jerry test");

//setMessage和setSingleChoiceItems、setMultiChoiceItems不能并列使用

//builder00.setMessage("android dialog test");

builder00.setMultiChoiceItems(new String[]{"aa","bb","cc","dd","ee","ff"}, new boolean[6], new DialogInterface.OnMultiChoiceClickListener()

{

public void onClick(DialogInterface dialog, int which, boolean isChecked)

{

// TODO Auto-generated method stub

Log.v("jin", "which="+which+" "+"ischecked="+isChecked);

}

});

AlertDialog alertDialog=builder00.create();

alertDialog.show();

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值