• 第三次作业











    <?
    xml version="1.0" encoding="utf-8"?>

    <android.support.constraint.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">
    
    <ImageView
        android:id="@+id/picture"
        android:layout_width="121dp"
        android:layout_height="116dp"
        android:layout_centerHorizontal="true"
        android:layout_marginStart="33dp"
        android:layout_marginLeft="33dp"
        android:layout_marginTop="100dp"
        android:layout_marginEnd="33dp"
        android:layout_marginRight="33dp"
        android:layout_marginBottom="30dp"
        android:src="@drawable/yanzhen"
        app:layout_constraintBottom_toTopOf="@+id/editText1"
        app:layout_constraintEnd_toEndOf="@+id/editText1"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="@+id/editText1"
        app:layout_constraintTop_toTopOf="parent" />
    
    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/editText2"
        android:layout_alignLeft="@+id/textView1"
        android:layout_alignBottom="@+id/editText2"
        android:layout_marginStart="48dp"
        android:layout_marginLeft="48dp"
        android:layout_marginEnd="25dp"
        android:layout_marginRight="25dp"
        android:text="密码:"
        android:textSize="20sp"
        app:layout_constraintBaseline_toBaselineOf="@+id/editText2"
        app:layout_constraintEnd_toStartOf="@+id/editText2"
        app:layout_constraintStart_toStartOf="parent" />
    
    <EditText
        android:id="@+id/editText2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_below="@+id/editText1"
        android:layout_alignLeft="@+id/editText1"
        android:layout_marginEnd="92dp"
        android:layout_marginRight="92dp"
        android:layout_marginBottom="35dp"
        android:ems="10"
        app:layout_constraintBottom_toTopOf="@+id/btn"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/textView2"
        app:layout_constraintTop_toBottomOf="@+id/editText1" />
    
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/btn"
        android:layout_alignBottom="@+id/editText1"
        android:layout_marginStart="48dp"
        android:layout_marginLeft="48dp"
        android:layout_marginEnd="25dp"
        android:layout_marginRight="25dp"
        android:text="账号:"
        android:textSize="20sp"
        app:layout_constraintBaseline_toBaselineOf="@+id/editText1"
        app:layout_constraintEnd_toStartOf="@+id/editText1"
        app:layout_constraintStart_toStartOf="parent" />
    
    <Button
        android:id="@+id/btn"
        android:layout_width="250dp"
        android:layout_height="wrap_content"
        android:layout_below="@+id/editText2"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="200dp"
        android:background="#3A5FCD"
        android:onClick="click"
        android:text="登录"
        android:textColor="#FFFFFF"
        app:layout_constraintBottom_toTopOf="@+id/tv"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.496"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/editText2" />
    
    <EditText
        android:id="@+id/editText1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_below="@+id/picture"
        android:layout_marginEnd="92dp"
        android:layout_marginRight="92dp"
        android:layout_marginBottom="39dp"
        android:layout_toRightOf="@+id/textView1"
        android:ems="10"
        android:textColor="#000000"
        android:textSize="20sp"
        app:layout_constraintBottom_toTopOf="@+id/editText2"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/textView1"
        app:layout_constraintTop_toBottomOf="@+id/picture">
    
        <requestFocus />
    </EditText>
    
    <TextView
        android:id="@+id/tv"
        android:layout_width="99dp"
        android:layout_height="44dp"
        android:layout_below="@+id/btn"
        android:layout_centerHorizontal="true"
        android:layout_marginStart="19dp"
        android:layout_marginLeft="19dp"
        android:layout_marginEnd="19dp"
        android:layout_marginRight="19dp"
        android:layout_marginBottom="41dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="@+id/editText2"
        app:layout_constraintHorizontal_bias="0.682"
        app:layout_constraintStart_toStartOf="@+id/editText2"
        app:layout_constraintTop_toBottomOf="@+id/btn" />
    />
    
    </android.support.constraint.ConstraintLayout>
    package com.example.yxyqq;
    
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Menu;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;
    import android.widget.Toast;
    
    public class MainActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
        }
    
        private TextView textView;
    
        public void click(View view) {
            Button btn = (Button) findViewById(R.id.btn);
            EditText et1 = (EditText) findViewById(R.id.editText1);
            EditText et2 = (EditText) findViewById(R.id.editText2);
            textView = (TextView) findViewById(R.id.tv);
            switch (view.getId()) {
                case R.id.btn:
    
                    String s1 = et1.getText().toString();
                    String s2 = et2.getText().toString();
                    if (s1.equals("123456") && s2.equals("abc123")) {
                        Toast.makeText(MainActivity.this, "登录成功", 0).show(); // 点击按钮时,在下面弹出消息框
                    } else {
                        textView.setText("登录失败");
                    }
            }
        }
    
    
    }
  • 相关阅读:
    ansible
    celery 计划任务使用
    11 session 使用
    10 模版继承和页面之间的调用
    9 模版语言 jinja2
    8 公共函数
    7 文件上传
    6 获取请求头和URL信息
    5 获取Form表单取值
    4 文件操作 支持图片 视频 mp3 文本等
  • 原文地址:https://www.cnblogs.com/yanzhen108/p/11489474.html
Copyright © 2020-2023  润新知