• 登陆界面


    <?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">
    
       <ImageView
           android:id="@+id/img1"
           android:layout_width="100dp"
           android:layout_height="100dp"
           android:layout_centerHorizontal="true"
           android:layout_marginTop="100dp"
           android:src="@drawable/pic1"
           android:contentDescription="@string/todo" />
       <LinearLayout
           android:id="@+id/layout"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:layout_below="@id/img1"
           android:layout_margin="10dp"
           android:orientation="vertical">
          <RelativeLayout
             android:id="@+id/regist_username"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
             android:layout_margin="5dp">
             <TextView
                android:id="@+id/tv_name"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:text="用户名:"
                android:textSize="20sp"/>
             <EditText
                android:id="@+id/et_name"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:layout_toRightOf="@id/tv_name"
                android:hint="请输入用户名"
                android:textSize="16sp"/>
          </RelativeLayout>
       <RelativeLayout
           android:id="@+id/regist_password"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:layout_margin="5dp">
          <TextView
              android:id="@+id/tv_psw"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_centerVertical="true"
              android:text="密    码:"
              android:textSize="20sp"/>
          <EditText
              android:id="@+id/et_psw"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginLeft="5dp"
              android:layout_toRightOf="@id/tv_psw"
              android:hint="请输入密码"
              android:textSize="16sp"/>
       </RelativeLayout>
       </LinearLayout>
    
       <Button
           android:layout_width="160dp"
           android:layout_height="48dp"
           android:layout_below="@id/layout"
           android:layout_centerHorizontal="true"
           android:layout_marginLeft="10dp"
           android:layout_marginTop="258dp"
           android:layout_marginRight="10dp"
           android:text="注册"
           android:textColor="#42579E"
           android:textSize="20sp"
           android:textStyle="bold"
           android:contentDescription="@string/todo"/>
    
       <TextView
           android:id="@+id/tv_sex"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_below="@id/layout"
           android:layout_marginLeft="30dp"
           android:layout_marginTop="29dp"
           android:text="性别:"
           android:textSize="23sp"
           android:visibility="visible" />
       <androidx.appcompat.widget.AppCompatRadioButton
           android:id="@+id/sex_man"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_below="@id/tv_sex"
           android:layout_marginLeft="30dp"
           android:text=""
           android:textSize="18sp"/>
       <androidx.appcompat.widget.AppCompatRadioButton
           android:id="@+id/sex_woman"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_below="@id/tv_sex"
           android:layout_marginLeft="30dp"
           android:layout_toRightOf="@id/sex_man"
           android:text=""
           android:textSize="18sp"/>
       <TextView
           android:id="@+id/tv_hobby"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_below="@id/tv_sex"
           android:layout_marginLeft="30dp"
           android:layout_marginTop="29dp"
           android:text="爱好:"
           android:textSize="23sp"
           android:visibility="visible" />
    
       <androidx.appcompat.widget.AppCompatCheckBox
          android:id="@+id/like_shuttlecock"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_marginLeft="30dp"
           android:layout_below="@id/tv_hobby"
          android:text="羽毛球"
          android:textSize="18sp"/>
       <androidx.appcompat.widget.AppCompatCheckBox
           android:id="@+id/like_basketball"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_below="@id/tv_hobby"
           android:layout_marginLeft="30dp"
           android:layout_toRightOf="@id/like_shuttlecock"
           android:text="篮球"
           android:textSize="18sp"/>
       <androidx.appcompat.widget.AppCompatCheckBox
           android:id="@+id/like_pingpong"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_toRightOf="@id/like_basketball"
           android:layout_marginLeft="30dp"
           android:layout_below="@id/tv_hobby"
           android:text="乒乓球"
           android:textSize="18sp"/>
    
    
    </RelativeLayout>
    <?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">
        <TextView
            android:id="@+id/tv_inform"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="100dp"
            android:layout_marginLeft="100dp"
            android:text="你的信息如下:"
            android:textSize="20sp"/>
        <TextView
            android:id="@+id/tv_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="150dp"
            android:layout_marginLeft="100dp"
            android:text="用户名:"
            android:textSize="20sp"/>
        <TextView
        android:id="@+id/tv_psw"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="100dp"
        android:layout_below="@id/tv_name"
        android:text="密    码:"
        android:textSize="20sp"/>
        <TextView
            android:id="@+id/tv_sex"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="100dp"
            android:layout_below="@id/tv_psw"
            android:text="性   别:"
            android:textSize="20sp"/>
        <TextView
            android:id="@+id/tv_hobby"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="100dp"
            android:layout_below="@id/tv_sex"
            android:text="爱   好:"
            android:textSize="20sp"/>
    </RelativeLayout>
    package com.example.logscreen;
    
    import androidx.appcompat.app.AppCompatActivity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.CheckBox;
    import android.widget.EditText;
    import android.widget.RadioButton;
    
    public class MainActivity extends AppCompatActivity {
    
        private EditText et_name;
        private EditText et_psw;
        private Button btn_send;
        private RadioButton sex_man;
        private RadioButton sex_woman;
        private CheckBox like_shuttlecock;
        private CheckBox like_basketball;
        private CheckBox like_pingpong;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
           et_name = (EditText) findViewById(R.id.et_name);
           et_psw = (EditText) findViewById(R.id.et_psw);
           sex_man = (RadioButton) findViewById(R.id.sex_man);
           sex_woman = (RadioButton) findViewById(R.id.sex_woman);
            like_shuttlecock = (CheckBox) findViewById(R.id.like_shuttlecock);
            like_basketball = (CheckBox) findViewById(R.id.like_basketball);
            like_pingpong = (CheckBox) findViewById(R.id.like_pingpong);
           btn_send = (Button) findViewById(R.id.btn_send);
    
           btn_send.setOnClickListener(new View.OnClickListener() {
               @Override
               public void onClick(View view) {
                   passdate();
               }
           });
        }
    
        private void passdate() {
            Intent intent = new Intent(this,ShowActivity.class);
            intent.putExtra("name",et_name.getText().toString().trim());
            intent.putExtra("password",et_psw.getText().toString().trim());
    
            startActivity(intent);
        }
    
    }
    package com.example.logscreen;
    import androidx.appcompat.app.AppCompatActivity;
    
    import android.content.Intent;
    import android.os.Bundle;
    import android.widget.TextView;
    
    public class ShowActivity extends AppCompatActivity{
        @Override
        protected void onCreate(Bundle savedInstanceStaate){
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_show);
            Intent intent = getIntent();
            String name = intent.getStringExtra("name");
            String password = intent.getStringExtra("password");
    
            TextView tv_name = (TextView) findViewById(R.id.et_name);
            TextView tv_psw = (TextView) findViewById(R.id.et_psw);
            tv_name.setText(name);
            tv_psw.setText(password);
        }
    
    }

  • 相关阅读:
    【leetcode】Valid Palindrome
    【leetcode】Longest Common Prefix
    【leetcode】Intersection of Two Linked Lists
    【leetcode】Compare Version Numbers
    【leetcode】Pascal's Triangle
    ubuntu 14.04下spark简易安装
    【leetcode】Number of 1 Bits
    【leetcode】LRU Cache
    【leetcode】Container With Most Water
    【leetcode】Roman to Integer
  • 原文地址:https://www.cnblogs.com/tianzhiyuan/p/13810928.html
Copyright © 2020-2023  润新知