android自定义AlertDialog

/**
	 * 显示自定义的alertdialog
	 */
	private void showAlertDialog(AppInfo pAppInfo)
	{
		final AppInfo mAppInfo = pAppInfo;
		final AlertDialog adl = new AlertDialog.Builder(HomeActivity.this).create();
		adl.setView(LayoutInflater.from(appContext).inflate(R.layout.app_alertdialog,null));
		adl.show();
		Window window = adl.getWindow();
		window.setContentView(R.layout.app_alertdialog);
		final EditText et_password = (EditText)window.findViewById(R.id.app_alertdialog_et_password);
		final Button btn_determine = (Button) window.findViewById(R.id.app_alertdialog_btn_determine);
		final Button btn_cancel = (Button) window.findViewById(R.id.app_alertdialog_btn_cancel);
		//确定按钮点击事件监听
		btn_determine.setOnClickListener(new OnClickListener(){
			@Override
			public void onClick(View v) 
			{
				if(et_password.getText().toString().equals(AppGlobal.Password))
				{
					LoadFile(mAppInfo,mAppInfo.getApp_url());
					adl.dismiss();
				}else{
					et_password.setText("");
				}
			}
		});
		//取消按钮点击事件监听
		btn_cancel.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				adl.cancel();
			}
		});
	}


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="409dp"
    android:layout_height="246dp"
    android:orientation="vertical"
    android:background="@drawable/alterdialog">
    <!-- 文本框  -->
    <EditText
        android:id="@+id/app_alertdialog_et_password"
        android:layout_width="345dp"
        android:layout_height="60dp"
        android:layout_marginLeft="33dp"
        android:layout_marginTop="85dp"
        android:inputType="textPassword"
        android:textAppearance="@style/app_text_style2" />
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="30dp">
        <!-- 确定按钮 -->
	    <Button
		    android:id="@+id/app_alertdialog_btn_determine"
		    android:layout_width="100dp"
		    android:layout_height="fill_parent"
		    android:background="@drawable/determine"
		    android:layout_marginLeft="80dp"/>
	    <!-- 取消按钮 -->
		<Button
		    android:id="@+id/app_alertdialog_btn_cancel"
		    android:layout_width="100dp"
		    android:layout_height="fill_parent"
		    android:background="@drawable/cancel"
		    android:layout_alignParentRight="true"
		    android:layout_marginRight="80dp"/>
    </RelativeLayout>
</RelativeLayout>


 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值