zoukankan      html  css  js  c++  java
  • 第三次作业

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@mipmap/l1">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="100dp"
            android:orientation="vertical"
            android:padding="30dp">
            <TextView
                android:id="@+id/text1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:drawableLeft="@mipmap/e2"
                android:layout_marginLeft="110dp"
                android:text="QQ"
                android:textSize="40sp" />
            <EditText
                android:id="@+id/edt1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="35dp"
                android:hint="QQ号/邮箱/手机号" />
            <EditText
                android:id="@+id/edt2"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:hint="密码"
                android:password="true"/>
    
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp">
            </RelativeLayout>
            <Button
                android:id="@+id/btn1"
                android:layout_width="match_parent"
                android:layout_margin="10dp"
                android:layout_height="40dp"
                android:text="登录"
    
                android:textSize="30sp"
                android:background="#87CEFF"
                android:onClick="click"
                />
        </LinearLayout>
    </RelativeLayout>
    package com.example.myapplication;
    import androidx.appcompat.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View.OnClickListener;
    import android.view.View;
    import android.widget.EditText;
    import android.widget.LinearLayout;
    import android.widget.TextView;
    import android.widget.Button;
    import android.widget.Toast;
    
    public class MainActivity extends AppCompatActivity {
        private Button btn1;
        EditText account = null;
        EditText code = null;
        EditText t1;
    
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            t1=(EditText) findViewById(R.id.edt1);
            account = (EditText) findViewById(R.id.edt1);
            code = (EditText) findViewById(R.id.edt2);
            btn1=(Button) findViewById(R.id.btn1);
            btn1.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View view) {
                    String username = ((EditText) findViewById(R.id.edt1)).getText().toString();
                    String pwd = ((EditText) findViewById(R.id.edt2)).getText().toString();
                    if (username.equals("123456") && pwd.equals("123456")) {
                        Toast.makeText(MainActivity.this,"登陆成功",Toast.LENGTH_SHORT).show();
    
                    } else {
                        t1.setText("账号或密码错误请重新输入");
                        Toast.makeText(MainActivity.this,"登陆失败",Toast.LENGTH_SHORT).show();
                    }
                }
    
            });
    
    
        }
    }

  • 相关阅读:
    [转]Maven类包冲突终极三大解决技巧
    python chardet 模块
    python pretty-errors模块
    认识执行时机
    python对象销毁顺序
    python字符串驻留
    python绘图练习
    小练习2
    小练习
    4G 内存处理 10G 大小的文件
  • 原文地址:https://www.cnblogs.com/mineral/p/11544458.html
Copyright © 2011-2022 走看看