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>
    
  • 相关阅读:
    北漂开始
    iOS沙盒简单介绍
    iOS多线程技术
    使用Redis实现分布式锁
    Spring Cloud构建微服务架构(六)高可用服务注册中心
    springboot学习之maven多环境打包的几种方式
    数据库中in和exists关键字的区别
    Java 中的悲观锁和乐观锁的实现
    springboot学习笔记-5 springboot整合shiro
    spring 整合 redis,以及spring的RedisTemplate如何使用
  • 原文地址:https://www.cnblogs.com/hualuoshuijia/p/6956594.html
Copyright © 2011-2022 走看看