zoukankan      html  css  js  c++  java
  • 安卓Activity用户注册界面

    <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=".MainActivity">
    
        <TextView
            android:id="@+id/tv1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="用户名:"
            android:textSize="30dp"
            android:layout_marginTop="30dp"
            android:textColor="#FFA500"
            />
    
        <EditText
            android:layout_width="600dp"
            android:layout_height="wrap_content"
            android:id="@+id/et1"
            android:layout_toRightOf="@id/tv1"
            android:layout_marginTop="20dp"
            android:textSize="30dp"
            />
    
        <TextView
            android:id="@+id/tv2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="密    码:"
            android:textSize="30dp"
            android:layout_marginTop="50dp"
            android:layout_below="@+id/tv1"
            android:textColor="#FFA500"
            />
    
        <EditText
            android:id="@+id/et2"
            android:layout_width="600dp"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/tv2"
            android:layout_marginTop="30dp"
            android:textSize="30dp"
            android:layout_below="@+id/et1"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="性别:"
            android:layout_marginLeft="1dp"
            android:layout_below="@id/tv2"
            android:layout_marginTop="20dp"
            android:textSize="40dp"
            android:textColor="#FF0000"/>
    <RadioGroup
        android:id="@+id/rb"
        android:layout_width="197dp"
        android:layout_height="wrap_content"
        android:layout_below="@id/tv2"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp">
    
        <RadioButton
            android:id="@+id/rb1"
            android:layout_width="97dp"
            android:layout_height="79dp"
            android:text="男"
            android:textSize="30dp"/>
    
        <RadioButton
            android:id="@+id/rb2"
            android:layout_width="97dp"
            android:layout_height="79dp"
            android:text="女"
            android:textSize="30dp" />
    </RadioGroup>
        <TextView
            android:id="@+id/tv3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="爱好:"
            android:layout_below="@id/rb"
            android:textSize="40dp"
            android:layout_marginLeft="1dp"
            android:textColor="#FF0000"/>
    <CheckBox
        android:layout_width="100dp"
        android:layout_height="60dp"
        android:id="@+id/cb1"
        android:layout_toRightOf="@id/tv3"
        android:layout_below="@id/rb"
        android:text="篮球"
        android:textSize="30dp"
        />
    
        <CheckBox
            android:layout_width="100dp"
            android:layout_height="60dp"
            android:id="@+id/cb2"
            android:layout_toRightOf="@id/cb1"
            android:layout_below="@id/rb"
            android:text="足球"
            android:textSize="30dp"
            />
        <CheckBox
            android:layout_width="100dp"
            android:layout_height="60dp"
            android:id="@+id/cb3"
            android:layout_toRightOf="@id/cb2"
            android:layout_below="@id/rb"
            android:text="排球"
            android:textSize="30dp"
            />
        <Button
            android:layout_width="150dp"
            android:layout_height="wrap_content"
            android:layout_below="@id/cb1"
            android:layout_centerHorizontal="true"
            android:text="注册"
            android:textSize="45dp"
            android:onClick="click"
            android:layout_marginTop="10dp"
            />
    </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=".TheSecond">
    
       <TextView
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:id="@+id/tv1"
           android:text="你的注册信息是:"
           android:textSize="30dp"
           android:layout_centerHorizontal="true"
           android:layout_marginTop="20dp"
           android:layout_marginBottom="50dp"
           />
        <TextView
            android:id="@+id/tv2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="用户名:"
            android:textSize="20dp"
            android:layout_below="@id/tv1"
            />
        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:id="@+id/et1"
            android:layout_marginTop="4dp"
            android:layout_toRightOf="@id/tv2"
            android:layout_below="@id/tv1"
            />
        <TextView
            android:id="@+id/tv3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="密    码:"
            android:textSize="20dp"
            android:layout_below="@id/tv2"
            />
        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:id="@+id/et2"
            android:layout_marginTop="8dp"
            android:layout_toRightOf="@id/tv2"
            android:layout_below="@id/et1"
            />
        <TextView
            android:id="@+id/tv4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="性    别:"
            android:textSize="20dp"
            android:layout_below="@id/tv3"
            />
        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:id="@+id/et3"
            android:layout_marginTop="8dp"
            android:layout_toRightOf="@id/tv2"
            android:layout_below="@id/et2"
            />
        <TextView
            android:id="@+id/tv5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="爱    好:"
            android:textSize="20dp"
            android:layout_below="@id/tv4"
            />
        <TextView
            android:layout_width="100dp"
            android:layout_height="wrap_content"
            android:id="@+id/et4"
            android:layout_marginTop="8dp"
            android:layout_toRightOf="@id/tv2"
            android:layout_below="@id/et3"
            />
    
    
    </RelativeLayout>
    

      

    package com.example.register;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.CheckBox;
    import android.widget.EditText;
    import android.widget.RadioGroup;
    
    public class MainActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        }
    
        public void click(View v){
            String name =((EditText)findViewById(R.id.et1)).getText().toString();
            String password =((EditText)findViewById(R.id.et2)).getText().toString();
            Intent it1=new Intent(this,TheSecond.class);
            it1.putExtra("name",name);
            it1.putExtra("password",password);
            final RadioGroup size =(RadioGroup)findViewById(R.id.rb);
            int selected=size.getCheckedRadioButtonId();
    
            switch (selected){
                case R.id.rb1:
                    it1.putExtra("boy","男");
                    break;
                case R.id.rb2:
                    it1.putExtra("girl","女");
                    break;
            }
            CheckBox c1=(CheckBox)findViewById(R.id.cb1);
            CheckBox c2=(CheckBox)findViewById(R.id.cb2);
            CheckBox c3=(CheckBox)findViewById(R.id.cb3);
            if(c1.isChecked()){
                it1.putExtra("bask","篮球");
            }
            if(c2.isChecked()){
                it1.putExtra("foot","足球");
            }
            if(c3.isChecked()){
                it1.putExtra("volley","排球");
            }
            startActivity(it1);
        }
    
    
    }
    

      

    package com.example.register;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.widget.TextView;
    
    public class TheSecond extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_the_second);
        }
    
        @Override
        protected void onStart() {
            super.onStart();
    
            Intent intent =getIntent();
            String name=intent.getStringExtra("name");
            String password=intent.getStringExtra("password");
            String boy=intent.getStringExtra("boy");
            String girl=intent.getStringExtra("girl");
            String bask=intent.getStringExtra("bask");
            String foot=intent.getStringExtra("foot");
            String volley=intent.getStringExtra("volley");
            TextView a=(TextView)findViewById(R.id.et1);
            TextView b=(TextView)findViewById(R.id.et2);
            TextView c=(TextView)findViewById(R.id.et3);
            TextView d=(TextView)findViewById(R.id.et4);
            a.setText(name);
            b.setText(password);
            if (bask==null){
                bask="";
            }
            if(foot==null){
                foot="";
            }
            if (volley==null){
                volley="";
            }
            if (girl==null){
                girl="";
            }
            if(boy==null){
                boy="";
            }
            c.setText(girl+boy);
            d.setText(bask+foot+volley);
        }
    }
    

      用户主界面

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.register">
    
        <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:roundIcon="@mipmap/ic_launcher_round"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">
    
            <activity
                android:name=".TheSecond"
                android:label="@string/app_name">
                </activity>
    
            <activity
                android:name=".MainActivity"
                android:label="@string/app_name">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
    
        </application>
    
    </manifest>
    

      

  • 相关阅读:
    下载安装ngnix
    微信小程序富文本中的图片大小超出屏幕
    微信小程序跳转(当我们不知道是普通页面还是tabbar)
    查看每年用量最多技术框架
    vue.js--遇到的一些错误
    vue-router(配置子路由--单页面多路由区域操作)
    webpack配置文件--(loader)
    webpack配置(入口出口)
    数组排序
    2021年12种高级UX/UI设计趋势
  • 原文地址:https://www.cnblogs.com/overCROSS/p/13887679.html
Copyright © 2011-2022 走看看