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

  • 相关阅读:
    linux根目录空间不足
    兴趣点 / 关键点( Interest point/Keypoint )
    opencv批量修改图片尺寸
    Excel批量修改文件
    xm数据写入
    opencv矩阵操作
    SVM参数解析
    Mat取行或列
    clone()与image和 cloneTo()
    最大连通域(指针)
  • 原文地址:https://www.cnblogs.com/xiaoxiaomeng/p/5679815.html
Copyright © 2011-2022 走看看