zoukankan      html  css  js  c++  java
  • android showDialog用法

    protected Dialog onCreateDialog(int id) {  
            // TODO Auto-generated method stub  
            switch(id){  
            case 10:  
                return new AlertDialog.Builder(Activity13.this)  
                .setTitle(getString(R.string.title)).setMessage(  
                        getString(R.string.timeout)).setPositiveButton(  
                        getString(R.string.ok),  
                        new DialogInterface.OnClickListener() {  
                            public void onClick(DialogInterface dialog,  
                                    int which) {  
                            }  
                        }).create();  
          
            }  
            return super.onCreateDialog(id);  
        }  
    

     调用:

    showDialog(10);
    

     

    自定义的view:

     View  dialogView=(LinearLayout) getLayoutInflater().inflate(R.layout.dialog_addip,null);
            final AlertDialog.Builder builder =new AlertDialog.Builder(Demo12Activity.this);
            builder.setView(dialogView);
            showBtn = (Button)findViewById(R.id.show);
            showBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                                                   //这
                    builder.show();
                }
            });
    
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="210dp"
            android:background="@drawable/radius_5dp"
            android:layout_marginLeft="12dp"
            android:layout_marginRight="12dp"
            android:padding="12dp"
            android:orientation="vertical">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:layout_marginBottom="20dp"
                android:textColor="#f75830"
                android:textSize="18dp"
                android:text="添加ip"/>
    
          
        </LinearLayout>
    
    </LinearLayout>
    
  • 相关阅读:
    Tomcat配置文件源码分析--server.xml详解
    Tomcat配置文件源码分析--Catalina.bat
    Linux安装JDK详细操作步骤
    Nginx项目发布成功之后,再次启动服务器无法访问(解决办法)
    Nginx发布项目完整过程
    图书管理系统需求分析报告
    tigergraph 创建 字符串分割函数(c++)
    (第一周)第一周学习收获
    Ubuntu 挂载iso文件
    Ubuntu 安装ifconfig命令
  • 原文地址:https://www.cnblogs.com/hualuoshuijia/p/6956594.html
Copyright © 2011-2022 走看看