zoukankan      html  css  js  c++  java
  • 安卓第七次作业

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout 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="wrap_content"
        android:layout_height="wrap_content"
        tools:context=".MainActivity"
        android:background="#f7f7f7"
        android:orientation="vertical"
        >
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="80dp"
            android:layout_centerHorizontal="true"
            app:srcCompat="@mipmap/xlaj" />
    </RelativeLayout>
       <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        >
        <TextView
            android:id="@+id/textView"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="账号"
            android:textSize="25sp"
            android:layout_weight="2"
            />
        <EditText
            android:id="@+id/editText"
            android:layout_width="0dp"
            android:layout_height="50dp"
            android:layout_weight="11"
            />
    
    </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >
    
            <TextView
                android:id="@+id/textView3"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="密码"
                android:textSize="25sp"
                android:layout_weight="2"
                />
            <EditText
                android:id="@+id/editText2"
                android:layout_width="0dp"
                android:layout_height="50dp"
                android:layout_weight="11"
                />
    
        </LinearLayout>
    
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <Button
            android:id="@+id/button"
            android:layout_width="380dp"
            android:layout_height="wrap_content"
            android:text="登录"
            android:background="#248dc1"
            android:onClick="click"
            android:layout_centerHorizontal="true"
            />
    </RelativeLayout>
    </LinearLayout>
    复制代码
    复制代码
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".Main2Activity">
       <LinearLayout
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:orientation="vertical"
           android:layout_centerInParent="true">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >
            <TextView
                android:id="@+id/textView"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="输入的账号为"
                android:textSize="25sp"
                android:layout_weight="7"
                />
            <TextView
                android:id="@+id/editText"
                android:layout_width="0dp"
                android:layout_height="50dp"
                android:layout_weight="11"
                android:text=" "
                />
    
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >
            <TextView
                android:id="@+id/textView3"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:text="输入的密码为"
                android:textSize="25sp"
                android:layout_weight="7"
                />
            <TextView
                android:id="@+id/editText2"
                android:layout_width="0dp"
                android:layout_height="50dp"
                android:layout_weight="11"
                android:text=""
                />
        </LinearLayout>
    </LinearLayout>
    </RelativeLayout>
    复制代码
    复制代码
    package cn.itcase.qq;
    
    import androidx.appcompat.app.AppCompatActivity;
    
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;
    import android.widget.Toast;
    
    public class MainActivity extends AppCompatActivity {
        private Button button;
        private EditText editText, editText2;
        private  TextView textView2;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            button = (Button) findViewById(R.id.button);
            editText = (EditText) findViewById(R.id.editText);
            editText2 = (EditText) findViewById(R.id.editText2);
        }
        public void  click(View view){
            String ID="123456";
            String PassWord="abc123";
            String s1=editText.getText().toString();
            String s2=editText2.getText().toString();
            if (ID.equals(s1)&&PassWord.equals(s2)) {
                Toast.makeText(MainActivity.this, "登陆成功", Toast.LENGTH_SHORT).show();
            }
            else {
                Toast.makeText(MainActivity.this, "登录失败", Toast.LENGTH_SHORT).show();
            }
            Intent intent =new Intent(MainActivity.this,Main2Activity.class);
            intent.putExtra("zh",s1);
            intent.putExtra("mm",s2);
            startActivity(intent);
        }
    
    }
  • 相关阅读:
    RabbitMQ入门(二)工作队列
    RabbitMQ入门之Hello World
    利用JMeter测试Tornado的多线程
    使用SQLAlchemy操作MySQL
    计算斐波那契数列的性能对比:Python,Java,Go
    PyCharm使用之配置SSH Interpreter
    Android数据绑定技术一,企业级开发
    Retrofit网络请求库应用02——json解析
    Servlet与Jsp的结合使用实现信息管理系统二
    Retrofit网络请求库应用01
  • 原文地址:https://www.cnblogs.com/9428zzz/p/11674219.html
Copyright © 2011-2022 走看看