• 第七次作业


     mainactivity.java

    package com.example.tangya;
    
    import androidx.appcompat.app.AppCompatActivity;
    
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.EditText;
    import android.widget.TextView;
    import android.widget.Toast;
    
    public class MainActivity extends AppCompatActivity {
        EditText zh;
        EditText mm;
        TextView ts;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            zh=(EditText) findViewById(R.id.et1);
            mm=(EditText) findViewById(R.id.et2);
        }
    
        public void denglu(View view) {
            String z=zh.getText().toString();
            String m=mm.getText().toString();
            if (z.equals(m)){
                Intent intent=new Intent();
                intent.setClass(MainActivity.this,M1Activity.class);
                intent.putExtra("name",z);
                intent.putExtra("pwd",m);
                startActivity(intent);
                Toast.makeText(MainActivity.this, "登陆成功",Toast.LENGTH_SHORT ).show();
            }else {
                Toast.makeText(MainActivity.this, "登陆失败",Toast.LENGTH_SHORT ).show();
                finish();
                overridePendingTransition(0,0);
            }
    
        }
    }

    m2activity.java

    package com.example.tangya;
    
    import androidx.appcompat.app.AppCompatActivity;
    
    import android.content.Intent;
    import android.os.Bundle;
    import android.widget.TextView;
    
    public class M1Activity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_m1);
            Intent intent=getIntent();
            String nam=intent.getStringExtra("name");
            String mm=intent.getStringExtra("pwd");
            TextView na=(TextView)findViewById(R.id.n);
            TextView mi=(TextView)findViewById(R.id.m);
            na.setText(nam);
            mi.setText(mm);
        }
    }
    

    man.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="#ECE4E4"
    
    
        >
    
        <ImageView
            android:id="@+id/imageView"
            android:layout_width="80sp"
            android:layout_height="80sp"
            app:srcCompat="@drawable/logo"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="100sp"
            />
    
        <LinearLayout
            android:id="@+id/lzh"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/imageView"
            android:layout_marginTop="50dp"
            android:background="#FFFFFF"
            android:layout_marginLeft="20sp"
            android:layout_marginRight="20sp"
            android:orientation="horizontal">
    
            <TextView
                android:id="@+id/id"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="15dp"
                android:text="账号:"
                android:textStyle="bold"
                android:textSize="20sp" />
    
            <EditText
                android:id="@+id/et1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#FFFFFF"
                android:padding="10dp">
    
            </EditText>
        </LinearLayout>
    
        <LinearLayout
            android:id="@+id/mm"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/lzh"
            android:layout_marginTop="50dp"
            android:background="#FFFFFF"
            android:layout_marginLeft="20sp"
            android:layout_marginRight="20sp"
            android:orientation="horizontal">
    
            <TextView
                android:id="@+id/pw"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="15dp"
                android:text="密码:"
                android:textStyle="bold"
                android:textSize="20sp" />
            <EditText
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:password="true"
                android:id="@+id/et2"
                android:padding="10dp"
                android:background="#FFFFFF">
    
            </EditText>
        </LinearLayout>
    
        <Button
            android:id="@+id/qr"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="登录"
            android:textStyle="bold"
            android:textColor="#FFFFFF"
            android:textSize="30sp"
            android:background="#2196F3"
            android:layout_below="@+id/mm"
            android:layout_marginTop="60dp"
            android:layout_marginLeft="40dp"
            android:layout_marginRight="40dp"
            android:onClick="denglu"
            />
    
        <TextView
            android:id="@+id/tv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/qr"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="50dp"
            android:text=""
            android:textColor="#F44336"
            android:textSize="20sp"
            android:textStyle="bold" />
    </RelativeLayout>
    

      two.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=".M1Activity">
    <TextView
        android:layout_width="wrap_content"
        android:text="welcome to login"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_margin="40dp"
        android:layout_above="@+id/zh"
        android:textSize="40sp"
        >
    
    </TextView>
        <LinearLayout
            android:id="@+id/zh"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="20sp"
            android:layout_marginRight="20sp">
            <TextView
                android:id="@+id/z"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="你的账号是:"
                >
            </TextView>
            <TextView
                android:id="@+id/n"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="20sp"
                android:textColor="#D236B1D6"
                android:text=""
                >
            </TextView>
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_marginTop="30sp"
            android:layout_marginLeft="20sp"
            android:layout_marginRight="20sp"
            android:layout_below="@id/zh">
            <TextView
                android:id="@+id/mm"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="你的密码是:"
                >
            </TextView>
            <TextView
                android:id="@+id/m"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="20sp"
                android:textColor="#D236B1D6"
                android:text=""
                >
            </TextView>
        </LinearLayout>
    </RelativeLayout>
  • 相关阅读:
    (15)树莓派系统安装和备份
    (0-0) 树莓派学习资料
    (14)树莓派
    (0-1) 树莓派常用软件及服务
    (13)flask搭建服务器
    (12)树莓派串口通信
    OpenCV 学习笔记(0)两幅图像标定配准
    OpenCV 学习笔记(9)RGB转换成灰度图像的一个常用公式Gray = R*0.299 + G*0.587 + B*0.114
    OpenCV 学习笔记(8)彩色图像RGB通道的分离、合并与显示
    Arduino OV7670 live image over USB to PC
  • 原文地址:https://www.cnblogs.com/TSHEN/p/11648748.html
Copyright © 2020-2023  润新知