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

  • 相关阅读:
    python-全局变量是否使用global总结
    python-多线程创建以及查看
    python-tcp客户端
    python-udp聊天器
    python-udp接受数据
    python-udp发送数据
    python-正则表达式总结
    JAVA程序员面试必知32个知识点
    计算机专业英语基础篇
    非常经典有深度的电影英文台词
  • 原文地址:https://www.cnblogs.com/xiaoxiaomeng/p/5679815.html
Copyright © 2011-2022 走看看