zoukankan      html  css  js  c++  java
  • 第七次作业-qq登录&跳转


    <?
    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);
        }
    
    }
    package cn.itcase.QQ;
    
    import androidx.appcompat.app.AppCompatActivity;
    
    import android.content.Intent;
    import android.os.Bundle;
    import android.widget.TextView;
    
    public class Main2Activity extends AppCompatActivity {
        private TextView editText, editText2;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main2);
            editText = (TextView) findViewById(R.id.editText);
            editText2 = (TextView) findViewById(R.id.editText2);
            Intent intent=getIntent();
            String zh=intent.getStringExtra("zh");
            String mm=intent.getStringExtra("mm");
            editText.setText(zh);
            editText2.setText(mm);
        }
    
    }
    
    
    
     
  • 相关阅读:
    [Oracle][Partition][Controlfile]Partition 操作是否和 Controlfile有关?
    [Oracle]如何观察Table 的各种Lock 之间的冲突
    [Oralce][InMemory]如何确定一个表已经被Populate 到In Memory 中?
    Arduino和C51之串口通信
    XC文件管理器-打造优美易用的文件管理器
    Android 控件进阶修炼-仿360手机卫士波浪球进度控件
    Android控件进阶-自定义流式布局和热门标签控件
    Windows开发之VC++仿QQ迷你首页(迷你资讯)
    Android自定义控件进阶-打造Android自定义的下拉列表框控件
    Android 自定义控件-高仿猎豹清理大师自定义内存开口圆环控件
  • 原文地址:https://www.cnblogs.com/yanzhen108/p/11728145.html
Copyright © 2011-2022 走看看