Android入门第九篇之AlertDialog
时隔一年,又要准备做Android的开发了,最近复习和整理一下Android的知识。这次要说的是AlertDialog,这种对话框会经常遇到。AlertDialog跟WIN32开发中的Dialog不一样,AlertDialog是非阻塞的,而阻塞的对话框用的是PopupWindow。
先贴出程序运行的截图:

main.xml的源码:
package com.testAlertDialog;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.PopupWindow;
public class testAlertDialog extends Activity {
Button btnShowDialog;
Button btnShowDialog_Layout;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//定义按钮
btnShowDialog=(Button)this.findViewById(R.id.Button01);
btnShowDialog.setOnClickListener(new ClickEvent());
btnShowDialog_Layout=(Button)this.findViewById(R.id.Button02);
btnShowDialog_Layout.setOnClickListener(new ClickEvent());
}
//统一处理按键事件
class ClickEvent implements OnClickListener{
相关推荐
csdnuuu 2020-01-29
rookieding 2012-01-29
mirahs 2019-06-28
MrDuoduo 2014-06-05
齐北的小村 2014-04-15
rookieding 2013-04-26
wolfoxkao 2013-02-20
凉白开 2012-12-03
yinge00 2012-06-17
源码在手 2012-04-18
如竹 2011-11-13
移动开发者 2011-10-28
huangkun 2011-10-27
huzhenv 2011-10-12
ustcrding 2011-09-04
sgafdsg 2011-02-21
Mexican 2010-07-20
wangkuifeng0 2010-07-20