zoukankan      html  css  js  c++  java
  • Dialog 学习备忘

    
    Dialog 学习备忘
    
    
    package com.eoeAndroid.dialog;
    
    import android.app.Activity;
    import android.app.AlertDialog;
    import android.app.Dialog;
    import android.app.ProgressDialog;
    import android.content.Context;
    import android.content.DialogInterface;
    import android.os.Bundle;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    
    public class ActivityMain extends Activity {
    	private static final int DIALOG1 = 1;
    	private static final int DIALOG2 = 2;
    
    	@Override
    	protected Dialog onCreateDialog(int id) {
    		switch (id) {
    		case DIALOG1:
    			return buildDialog1(ActivityMain.this);
    
    		case DIALOG2:
    			return buildDialog2(ActivityMain.this);
    
    		}
    		return null;
    	}
    	
    	protected void onPrepareDialog(int id, Dialog dialog){
    		if(id==DIALOG1){
    			setTitle("测试");
    		}
    	}
    
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.alert_dialog);
    
    		Button button1 = (Button) findViewById(R.id.button1);
    		button1.setOnClickListener(new OnClickListener() {
    			@SuppressWarnings("deprecation")
    			public void onClick(View v) {
    				showDialog(DIALOG1);
    			}
    		});
    
    		Button buttons2 = (Button) findViewById(R.id.buttons2);
    		buttons2.setOnClickListener(new OnClickListener() {
    			@SuppressWarnings("deprecation")
    			public void onClick(View v) {
    				showDialog(DIALOG2);
    			}
    		});
    	}
    
    	private Dialog buildDialog1(Context context) {
    		LayoutInflater inflater = LayoutInflater.from(this);
    		final View textEntryView = inflater.inflate(
    				R.layout.alert_dialog_text_entry, null);
    		AlertDialog.Builder builder = new AlertDialog.Builder(context);
    		builder.setIcon(R.drawable.alert_dialog_icon);
    		builder.setTitle(R.string.alert_dialog_text_entry);
    		builder.setView(textEntryView);
    		builder.setPositiveButton(R.string.alert_dialog_ok,
    				new DialogInterface.OnClickListener() {
    					public void onClick(DialogInterface dialog, int whichButton) {
    						setTitle("点击了对话框上的确定按钮");
    					}
    				});
    		builder.setNegativeButton(R.string.alert_dialog_cancel,
    				new DialogInterface.OnClickListener() {
    					public void onClick(DialogInterface dialog, int whichButton) {
    						setTitle("点击了对话框上的取消按钮");
    					}
    				});
    		return builder.create();
    	}
    	
    
    	private Dialog buildDialog2(Context context) {
    		ProgressDialog dialog = new ProgressDialog(context);
    		dialog.setTitle("正在下载歌曲");
    		dialog.setMessage("请稍候……");
    		return  dialog;
    	}
    }


  • 相关阅读:
    质量数据统计报表
    Gitlab CR
    搭建openstf平台的那些事
    wrk 使用记录及踩过的坑
    无题,表达一下心情
    theano中对图像进行convolution 运算
    4d tensor
    theano中的concolutional_mlp.py学习
    theano中的logisticregression代码学习
    利用Anaconda安装python后,如何安装opencv-python
  • 原文地址:https://www.cnblogs.com/wangmingshuo/p/3323409.html
Copyright © 2011-2022 走看看