• 第三次作业


     1 <?xml version="1.0" encoding="utf-8"?>
     2 <RelativeLayout
     3     xmlns:android="http://schemas.android.com/apk/res/android"
     4     xmlns:app="http://schemas.android.com/apk/res-auto"
     5     xmlns:tools="http://schemas.android.com/tools"
     6     android:layout_width="match_parent"
     7     android:layout_height="match_parent"
     8     android:background="#009688"
     9     tools:context=".MainActivity">
    10     <Button
    11         android:id="@+id/button"
    12         android:layout_width="match_parent"
    13         android:layout_height="wrap_content"
    14         android:layout_marginLeft="20dp"
    15         android:layout_marginRight="20dp"
    16         android:text="登录"
    17         android:textSize="30dp"
    18         android:textColor="#FCF8F7"
    19         android:background="#2196F3"
    20         tools:layout_editor_absoluteX="165dp"
    21         tools:layout_editor_absoluteY="224dp"
    22         android:layout_centerHorizontal="true"
    23         android:layout_centerVertical="true"
    24         android:onClick="qq"
    25         />
    26 
    27     <LinearLayout
    28         android:layout_width="match_parent"
    29         android:layout_height="wrap_content"
    30         android:layout_below="@+id/imageView"
    31         android:layout_marginTop="90dp"
    32         android:background="#FFFFFF"
    33         android:orientation="horizontal">
    34 
    35         <TextView
    36             android:layout_width="wrap_content"
    37             android:layout_height="wrap_content"
    38             android:text="密码:" />
    39 
    40         <EditText
    41             android:id="@+id/mima"
    42             android:layout_width="match_parent"
    43             android:layout_height="wrap_content"
    44             android:hint="输入密码"
    45             android:textColorHint="#1CB9B3"
    46 
    47 
    48             android:layout_marginLeft="20dp" />
    49     </LinearLayout>
    50     <LinearLayout
    51         android:layout_width="match_parent"
    52         android:layout_height="wrap_content"
    53         android:layout_below="@+id/imageView"
    54         android:layout_marginTop="30dp"
    55         android:background="#FFFFFF"
    56         android:orientation="horizontal">
    57 
    58         <TextView
    59             android:layout_width="wrap_content"
    60             android:layout_height="wrap_content"
    61             android:text="账号:" />
    62 
    63         <EditText
    64             android:id="@+id/zh"
    65             android:layout_width="match_parent"
    66             android:layout_height="wrap_content"
    67             android:hint="输入账号"
    68             android:textColorHint="#358691"
    69 
    70             android:layout_marginLeft="20dp" />
    71     </LinearLayout>
    72     <ImageView
    73         android:id="@+id/imageView"
    74         android:layout_width="80dp"
    75         android:layout_height="80dp"
    76         android:layout_marginTop="50dp"
    77         android:layout_centerHorizontal="true"
    78         app:srcCompat="@drawable/ty" />
    79 
    80 </RelativeLayout>
    package com.example.m;
    
    import androidx.appcompat.app.AppCompatActivity;
    
    import android.os.Bundle;
    import android.view.View;
    import android.widget.EditText;
    import android.widget.Toast;
    
    public class MainActivity extends AppCompatActivity {
        EditText zh;
        EditText mima;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            zh=findViewById(R.id.zh);
            mima=findViewById(R.id.mima);
        }
    
        public void qq(View view) {
            String z=zh.getText().toString();
            String m=mima.getText().toString();
            if (z.equals("1234")){
                if (m.equals("1234")){
    
                    Toast.makeText(MainActivity.this,"登陆成功",Toast.LENGTH_SHORT).show();
                }else {
    
                    Toast.makeText(MainActivity.this,"密码错误",Toast.LENGTH_SHORT).show();
    
                }
    
            }else{
    
                Toast.makeText(MainActivity.this,"登陆失败",Toast.LENGTH_SHORT).show();
            }
    
    
        }
    }
    

      

  • 相关阅读:
    WPF中图形表示语法详解(Path之Data属性语法)ZZ
    C#/.NET Little Wonders: Use Cast() and OfType() to Change Sequence Type(zz)
    WPF在DLL中读取Resource的方法
    CENTOS6.5安装CDH5.12.1(一) https://mp.weixin.qq.com/s/AP_m0QqKgzEUfjf0PQCX-w
    Buildroot stress-ng Linux系统压力测试
    Jenkins+git
    MySql5.7配置文件my.cnf设置
    mongoDB 删除集合后,空间不释放
    有赞MySQL自动化运维之路—ZanDB
    TIDB介绍 新数据库趋势
  • 原文地址:https://www.cnblogs.com/96111314w/p/11491608.html
Copyright © 2020-2023  润新知