• 第三次作业210


    1.xml代码

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout 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"
    android:background="@mipmap/p30">

    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#55000000"
    android:orientation="vertical"
    android:paddingLeft="30dp"
    android:paddingRight="30dp" >

    <LinearLayout
    android:layout_marginTop="80dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:orientation="horizontal" >


    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="QQ"
    android:textColor="#fff"
    android:textSize="50dp" />
    </LinearLayout>

    <EditText
    android:id="@+id/userid"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="30dp"
    android:background="@null"
    android:hint="QQ号/手机号/邮箱"
    android:maxLength="13"
    android:singleLine="true"
    android:textColor="#fff"
    android:textSize="25sp"
    android:textColorHint="#eee" />

    <View
    android:layout_width="match_parent"
    android:layout_height="1px"
    android:layout_marginTop="10dp"
    android:background="#eee" />

    <EditText
    android:id="@+id/password"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:background="@null"
    android:hint="密码"
    android:inputType="textPassword"
    android:maxLength="13"
    android:singleLine="true"
    android:textColor="#fff"
    android:textSize="25dp"
    android:textColorHint="#eee" />

    <View
    android:layout_width="match_parent"
    android:layout_height="1px"
    android:layout_marginTop="10dp"
    android:background="#eee" />

    <Button
    android:id="@+id/login"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:background="#aaafff"
    android:text="登录"
    android:textColor="#fff"
    android:textSize="25sp" />

    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:orientation="horizontal" >

    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:text="忘记密码?"
    android:textColor="#cc1CA4DE"
    android:textSize="20dp" />

    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:gravity="right"
    android:text="新用户注册"
    android:textColor="#cc1CA4DE"
    android:textSize="20dp" />
    </LinearLayout>
    </LinearLayout>

    </RelativeLayout>

    2.Java代码

    package com.example.qq123;

    import androidx.appcompat.app.AppCompatActivity;

    import android.os.Bundle;
    import android.util.Log;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.Toast;

    public class MainActivity extends AppCompatActivity {
    EditText userid;  //声明控件
    EditText password;
    Button login;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);  //标题设置
    setContentView(R.layout.activity_main);
    userid=(EditText)findViewById(R.id.userid); //控件的初始化
    password=(EditText)findViewById(R.id.password);
    login=(Button)findViewById(R.id.login);   //监听
    login.setOnClickListener(new View.OnClickListener() {

    @Override   //方法的调用

    public void onClick(View view) {

    String userid =((EditText)findViewById(R.id.userid)).getText().toString();
    String password =((EditText)findViewById(R.id.password)).getText().toString();
    if (userid.equals("123456")&&password.equals("123456")) {
    Toast t1 = Toast.makeText(getApplicationContext(), "登录成功", Toast.LENGTH_SHORT);
    t1.show();
    }
    else {
    Toast t2 = Toast.makeText(getApplicationContext(), "登录失败", Toast.LENGTH_SHORT);
    t2.show();
    }

    }
    });
    }
    }

    3.图片

     

     

  • 相关阅读:
    CentOS7使用firewalld打开关闭防火墙与端口
    ssh连接卡在【To escape to local shell, press 'Ctrl+Alt+]'.】的解决方法
    本地链路地址
    RIFF和WAVE音频文件格式
    声音分贝的概念,dBSPL.dBm,dBu,dBV,dBFS
    VS中C++ 项目重命名
    FFmpeg学习6:视音频同步
    FFmpeg学习5:多线程播放视音频
    FFmpeg学习4:音频格式转换
    FFmpeg数据结构:AVPacket解析
  • 原文地址:https://www.cnblogs.com/lixiaoai/p/11486096.html
Copyright © 2020-2023  润新知