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="match_parent"
        android:layout_height="match_parent"
    
    
    
        android:orientation="vertical"
        tools:context=".MainActivity">
    
        <ImageView
            android:id="@+id/iv"
    
            android:layout_width="90dp"
            android:layout_height="99dp"
            android:layout_margin="15dp"
            android:background="@drawable/a1"
            />
    
    
    
    
        <TextView
            android:id="@+id/textView"
            android:layout_width="match_parent"
            android:layout_height="90dp"
            android:background="	#90EE90"
            android:enabled="true"
            android:gravity="center"
            android:text="智慧校园注册系统"
            android:textColor="#00688B"
            android:textSize="30sp" />
    
        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:gravity="center">
    
            <TableRow
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center">
    
                <TextView
                    android:id="@+id/name"
                    android:layout_width="wrap_content"
                    android:layout_height="30dp"
                    android:enabled="true"
                    android:text="用户名/学号:"
                    android:textSize="20sp"
                    android:textStyle="bold" />
    
                <EditText
                    android:id="@+id/etname"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:ems="10"
                    android:inputType="textPersonName" />
            </TableRow>
    
            <TableRow
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center">
    
                <TextView
                    android:id="@+id/password"
                    android:layout_width="wrap_content"
                    android:layout_height="30dp"
                    android:enabled="true"
                    android:text="             密码:"
                    android:textSize="20sp"
                    android:textStyle="bold" />
    
                <EditText
                    android:id="@+id/etpass"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:ems="10"
                    android:inputType="numberPassword" />
    
            </TableRow>
        </TableLayout>
    
        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="150dp"
            android:gravity="center">
    
            <TableRow
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center">
    
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:enabled="true"
                    android:text="性别:"
                    android:textSize="20sp"
                    android:textStyle="bold" />
    
                <RadioGroup
                    android:id="@+id/rg"
                    android:layout_width="220dp"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">
    
                    <RadioButton
                        android:id="@+id/boy"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="男" />
    
                    <RadioButton
                        android:id="@+id/girl"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="女" />
                </RadioGroup>
            </TableRow>
    
            <TableRow
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:gravity="center">
    
                <TextView
                    android:id="@+id/textView7"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:enabled="true"
                    android:text="专业"
                    android:textSize="20sp"
                    android:textStyle="bold" />
    
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="horizontal">
    
                    <CheckBox
                        android:id="@+id/print"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="计算机"/>
    
                    <CheckBox
                        android:id="@+id/basketball"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="通信工程"/>
                </LinearLayout>
    
            </TableRow>
    
            <TableRow
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center">
    
                <TextView
                    android:id="@+id/textView8"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="20sp" />
    
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="horizontal">
    
                    <CheckBox
                        android:id="@+id/sing"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="机器人工程"/>
    
                    <CheckBox
                        android:id="@+id/dance"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="电气工程"/>
                </LinearLayout>
            </TableRow>
        </TableLayout>
    
        <Button
            android:id="@+id/button"
            android:layout_width="166dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:background="#FFE4E1"
            android:text="注册"
            android:textAllCaps="false"
            android:textColor="#252523"
            android:textStyle="bold" />
    
    </LinearLayout>
    

      

    package com.example.aaaapps;
    
    import androidx.appcompat.app.AppCompatActivity;
    
    import android.content.Intent;
    import android.os.Bundle;
    import android.os.Parcelable;
    import android.view.View;
    import android.widget.Button;
    import android.widget.CheckBox;
    import android.widget.CompoundButton;
    import android.widget.EditText;
    import android.widget.RadioButton;
    import android.widget.RadioGroup;
    import android.widget.TextView;
    
    import com.example.aaaapps.R;
    
    public class MainActivity extends AppCompatActivity implements CompoundButton.OnCheckedChangeListener {
    
        private String hobbys;
        final Intent intent = new Intent();
        private EditText name;
        private EditText password;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            name = (EditText)findViewById(R.id.etname);
            password = (EditText)findViewById(R.id.etpass);
            RadioGroup  rg = (RadioGroup)findViewById(R.id.rg);
            CheckBox print = (CheckBox)findViewById(R.id.print);
            CheckBox basketball = (CheckBox)findViewById(R.id.basketball);
            CheckBox sing = (CheckBox)findViewById(R.id.sing);
            CheckBox dance = (CheckBox)findViewById(R.id.dance);
            hobbys = new String();
    
            //设置跳转到的Activity
    
    
    
    
            //为RadioGroup设置监听
            rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(RadioGroup radioGroup, int i) {
                    if (i == R.id.girl){
                        intent.putExtra("gender", "女");
                    }else if (i == R.id.boy){
                        intent.putExtra("gender", "男");
                    }
                }
            });
    
            //为CheckBox设置监听
            print.setOnCheckedChangeListener(this);
            basketball.setOnCheckedChangeListener(this);
            sing.setOnCheckedChangeListener(this);
            dance.setOnCheckedChangeListener(this);
    
    
            //为 Button设置监听
            Button button = (Button)findViewById(R.id.button);
            button.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Bundle bundle = new Bundle();
                    bundle.putString("name",name.getText().toString());
                    bundle.putString("password",password.getText().toString());
                    intent.putExtras(bundle);
                    startActivity(intent);
    
                }
            });
        }
    
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            String motion = compoundButton.getText().toString();
            if (b){
                if(!hobbys.contains(motion)){
                    hobbys = hobbys + motion;
                    intent.putExtra("hobbys", hobbys);
                }
            }else{
                if (hobbys.contains(motion)){
                    hobbys = hobbys.replace(motion,"");
                    intent.putExtra("hobbys", hobbys);
                }
            }
        }
    }
    

      

  • 相关阅读:
    JAVAWE第一天
    01--2048实例开篇
    10--动作系统(四)动作类中的reverse方法
    09--动作系统(三)使用持续动作
    08--动作系统(二)使用即时动作
    【转】cocos2d-x windows开发环境配置
    07--动作系统(一)
    06--触摸事件响应
    05--简单场景切换与精灵创建
    04--简单菜单使用
  • 原文地址:https://www.cnblogs.com/s2me/p/13819841.html
Copyright © 2011-2022 走看看