zoukankan      html  css  js  c++  java
  • android 显示自定义视图对话框

    activity_main.xml:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="自定义视图对话框"
    android:id="@+id/btnCustomViewDialog"
    />

    </LinearLayout>

    dialog_custom.xml

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ProgressBar
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/progressBar"
    android:layout_gravity="center_horizontal"/>

    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Loading...."/>
    </LinearLayout>

    MainActivity.java:

    this.findViewById(R.id.btnCustomViewDialog).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
    builder.setTitle("自定义视图");
    View view = View.inflate(MainActivity.this,R.layout.dialog_custom,null);

    builder.setView(view);

    builder.show();
    }
    });

  • 相关阅读:
    export,source
    zookeeper安装笔记
    centos修改启动顺序,登录后提示,启动级别,主机名,免密登录
    CentOS卸载系统自带的OpenJDK
    处理有外键约束的数据
    linux iptables
    centos httpd服务做yum本地源,以及安装Mysql
    Linux命令(一)grep查询
    LaTeX符号和图片
    LaTeX文章结构
  • 原文地址:https://www.cnblogs.com/xiaoxiaomeng/p/5679815.html
Copyright © 2011-2022 走看看