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();
    }
    });

  • 相关阅读:
    IO
    NIO
    Nginx(六)之负载均衡策略
    Nginx(五)之事件相关实现
    Nginx(四)之模块功能
    Nginx(三)之配置指令与内部运行逻辑
    Nginx(二)之数据结构
    Nginx(一)之整体架构框架
    HTTP(二)Web安全
    gson哪些符号html转义,Gson-特殊字符的转义-disableHtmlEscaping()
  • 原文地址:https://www.cnblogs.com/xiaoxiaomeng/p/5679815.html
Copyright © 2011-2022 走看看