Android学习笔记13

今天做了dialogfragment,程序码如下

<?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="wrap_content"
    android:layout_marginLeft="50dp"
    android:layout_marginRight="50dp"
    android:orientation="vertical">

   <EditText
       android:id="@+id/account"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:hint="account"/>
   <EditText
       android:id="@+id/password"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:hint="password"/>
   <LinearLayout
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:orientation="horizontal">
      <Button
          android:id="@+id/login"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_weight="0.5"
          android:text="login"/>
      <Button
          android:id="@+id/cancel"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_weight="0.5"
          android:text="cancel"/>

   </LinearLayout>

</LinearLayout>

https://ithelp.ithome.com.tw/upload/images/20210922/20141791y5ZXntbpi3.png
然後在activity中这样调用

val fm = supportFragmentManager
val dialog = FragmentDialog()
dialog.show(fm,"Blossom")

结果如下
https://ithelp.ithome.com.tw/upload/images/20210922/201417915Vn7Kd8Km0.png
但是在activity中架构会变得不好看,正在研究好的方式在viewmodel中呈现


<<:  6. 恐惧支配到信任领导

>>:  [Day22] 使用官方提供的工具,吸引用户不断回来使用Action

DAY28 mongodb aggregate(2)

上次我们在mongo shell里使用mongodb aggregate 不过 我们需要在程序里面去...

DAY20 这边先帮你上一个按钮喔~(二)

昨天把骰子的程序逻辑都先完成了,这次我们将这个逻辑应用在 Android Studio 里。但我们今...

[Day 19] 资料产品的管理-资料治理初探

前面花了不少篇幅在讨论资料产品的开发,接下来将花一些篇幅讨论资料产品的治理方式。 在做资料产品治理时...

Day 16 网页分析 - Web Application Analysis (网页内容扫描器 - DIRB )

今天要介绍的工具是BIRDDIRB,是一个网页内容扫描器,它根据字典档一个个向目标网页发出请求,并分...

[Day2] CSS + JS Clock

[Day2] CSS + JS Clock 运用 CSS 和 Javascript 做一个虚拟时钟 ...