0
点赞
收藏
分享

微信扫一扫

docker desktop搭建 nginx

生命中最美的是成长 2023-08-13 阅读 67
android

Drawable:

Shape:

九宫格图片:

状态列表图形:

复选框CheckBox:

 <CheckBox
    	      android:id="@+id/ck_system"
    	      android:layout_width="match_parent"
      		  android:layout_height="wrap_content"
     	      android:padding="5dp"
      	      android:text="这是系统的CheckBox"/>

开关按钮Switch:

  <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="start"
            android:layout_weight="1"
            android:padding="5dp"
            android:text="这是一个switch开关的文本"/>
        <Switch
            android:layout_width="80dp"
            android:layout_height="30dp"
            android:layout_gravity="end"
            android:padding="5dp" />

单选按钮RadioButton:

    <RadioGroup                             
        android:id="@+id/rg_gender"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <RadioButton
            android:id="@+id/rb_male"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="男"/>
        <RadioButton
            android:id="@+id/rb_female"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="女"/>
    </RadioGroup>

编辑框EditText:

<EditText                              
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background=”@null”         //取消边框
        android:maxLength="16"             //最大输入文字
        android:hint="请输出用户名"         //提示文字
        android:inputType="text"/>           //输入类型

焦点变更监听器:(用于验证性)

et_phone = findViewById(R.id.et_phone);  //获取到号码数据
EditText et_password=findViewById(R.id.et_password); 
et_password.setOnFocusChangeListener(this);    //焦点变更监听方式
//检测焦点做判断
public void onFocusChange(View view, boolean hasFocus) { 
        if (hasFocus)                           
  {String phone= et_phone.getText().toString();
            //手机号码不足11位
          if (TextUtils.isEmpty(phone)||phone.length()<11)
      { et_phone.requestFocus();
            Toast.makeText(this,"请输入11位手机号码",Toast.LENGTH_SHORT).show();
      }    
   }    
                                                        }

文本变化监听器:

弹出类提醒对话框AlertDialog:

 public void onClick(View view) {
       //创建提醒对话框构建器
        AlertDialog.Builder builder =new AlertDialog.Builder(this);
        builder.setTitle("尊敬的用户");
        //设置对话框的内容文本
        builder.setMessage("你真的要卸载我嘛?");
        //设置对话框的肯定按钮文本及其点击监听
        builder.setPositiveButton("残忍卸载", (dialogInterface, i) -> {
            tv_alert.setText("我滚了,你照顾好自己");
        });
        //设置对话框否定按钮文本及监听
        builder.setNegativeButton("我再想想",(dialogInterface, i) -> {
            tv_alert.setText("你不离,我不弃");
        });
        //根据建造器构建提醒对话框对象
        AlertDialog dialog = builder.create();
        //显示提醒对话框
        dialog.show();  }

日期对话框DatePickerDialog:

    <DatePicker
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:datePickerMode="spinner"
        android:calendarViewShown="false"/>

时间对话框TimePickerDialog:

    <TimePicker
        android:id="@+id/tp_time"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

仅为个人笔记记录使用

举报

相关推荐

0 条评论