Day-18 EditText

EditText为提供使用者输入之元件,

而其中包括许多属性提供不同之用途,

下面列举出EditTedxt常见的属性


  • 设定列数:android:lines="最多可显示的列数"
  • 单列或多列:android:singleLine="true(单列)或false(多列)"
  • 设定字元数:android:ems="每列最多可显示的字数"(仅在width="wrap_content"时才有用)
  • 可否选中:android:enabled="false(不可选中)或true(可选中)"
  • 空时显示讯息:android:hint="欲显示之文字"
  • 资料类型:android:inputType="欲设定之type"

而常见的type如下图所示
https://ithelp.ithome.com.tw/upload/images/20211002/20141950VvcXXkSsCx.png
以下利用EditText进行简单的范例

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入密码"
        android:inputType="numberPassword"
        android:singleLine="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

https://ithelp.ithome.com.tw/upload/images/20211002/20141950RbEhxdeoJs.png
此范例type设定为numberPassword,
因此点开时会跳出数字键盘,
而输入的数字会自动进行隐藏


<<:  DAY 20-数位签章-ECDSA

>>:  Day17 Preparation of Gin and Env

JavaScript学习日记 : Day2 - 动态型别+弱型别

1. 静态型别 VS. 动态型别 1.1 静态型别的例子 以Java为例: int x 在宣告x变数...

#16 JS: loop - Part 1

while statement If the statement is true, the code...

DAY 3:Read-Write-Lock Pattern,三人成虎,一人打虎!

什麽是 Read-Write-Lock Pattern? 多读单写。将 lock 分为 read 与...

【第24天】部署API服务-GCP架设VM(二)

摘要 作业流程 安装环境/套件 上传打包後模型 介绍Vim编辑器 惨痛经历 内容 作业流程(今日进度...

提款、存款、汇款一次到位

提款 接下来,写个提款功能 # cogs/money.py @commands.command() ...