• 10.7


    <?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/tv1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="用户名:"
        android:textSize="30dp"
        android:layout_marginTop="60dp"
        />
    <EditText
        android:id="@+id/et1"
        android:layout_width="700dp"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/tv1"
        android:layout_marginTop="60dp"
        android:textSize="40dp"
        />
    
    <TextView
        android:id="@+id/tv2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="密码:"
        android:textSize="20dp"
        android:layout_marginTop="40dp"
        android:layout_below="@+id/tv1"
        />
    <EditText
        android:id="@+id/et2"
        android:layout_width="500dp"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/tv2"
        android:layout_marginTop="40dp"
        android:textSize="40dp"
        android:layout_below="@+id/et1"
    
        />
    
        <RadioGroup
            android:id="@+id/rg"
            android:layout_width="199dp"
            android:layout_height="wrap_content"
            android:layout_below="@+id/tv2"
           >
    
    
            <RadioButton
                android:id="@+id/rb1"
                android:layout_width="99dp"
                android:layout_height="59dp"
    
                android:text=""
                android:textSize="40dp" />
    
            <RadioButton
                android:id="@+id/rb2"
                android:layout_width="107dp"
                android:layout_height="99dp"
    
                android:text=""
                android:textSize="40dp" />
    
        </RadioGroup>
    <CheckBox
        android:id="@+id/cb1"
        android:layout_width="90dp"
        android:layout_height="67dp"
        android:layout_below="@+id/rg"
        android:layout_marginTop="57dp"
    
        android:text="篮球" />
    
    <CheckBox
        android:id="@+id/cb2"
        android:layout_width="50dp"
    
        android:layout_height="73dp"
        android:layout_below="@+id/rg"
        android:layout_marginLeft="64dp"
        android:layout_marginTop="40dp"
        android:layout_toRightOf="@+id/cb1"
        android:text="足球" />
    <CheckBox
        android:layout_marginTop="40dp"
        android:id="@+id/cb3"
    
        android:layout_width="70dp"
        android:layout_height="63dp"
        android:text="羽毛球"
        android:layout_below="@+id/rg"
        android:layout_toRightOf="@+id/cb2"
        android:layout_marginLeft="65dp"
        />
        <Button
            android:layout_marginTop="80dp"
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:text="注册"
            android:textSize="20dp"
            android:layout_below="@+id/cb3"
            android:layout_centerHorizontal="true"
            android:onClick="click"
            />
    </RelativeL
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <TextView
            android:id="@+id/tv1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="你的注册信息是"
            android:textSize="40dp"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="60dp"
            android:layout_marginBottom="40dp"
            />
        <TextView
            android:layout_marginTop="50dp"
            android:id="@+id/tv2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="用户名"
            android:textSize="50dp"
            android:layout_below="@+id/tv1"
            />
        <TextView
            android:id="@+id/et1"
            android:layout_marginTop="40dp"
            android:layout_width="400dp"
            android:layout_height="wrap_content"
            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="40dp"
            android:layout_below="@+id/tv2"
            android:layout_marginTop="40dp"
            />
        <TextView
            android:id="@+id/et2"
            android:layout_width="700dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:layout_toRightOf="@+id/tv3"
            android:layout_below="@+id/tv2"
            />
        <TextView
            android:id="@+id/tv4"
            android:layout_width="wrap_content"
            android:layout_marginTop="30dp"
            android:layout_height="wrap_content"
            android:text="性别"
            android:textSize="30dp"
            android:layout_below="@+id/tv3"
            />
        <TextView
            android:id="@+id/et3"
            android:layout_width="700dp"
            android:layout_marginTop="30dp"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/tv4"
            android:layout_below="@+id/tv3"
            />
        <TextView
            android:id="@+id/tv5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="40dp"
            android:text="爱好"
            android:textSize="40dp"
            android:layout_below="@+id/tv4"
            />
        <TextView
            android:id="@+id/et4"
            android:layout_width="400dp"
            android:layout_marginTop="40dp"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@+id/tv5"
            android:layout_below="@+id/tv4"
            />
    </RelativeLayout>
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.myapplication">
    
        <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=".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>
            <activity
                android:name=".ShowActivity"
                android:label="@string/app_name">
    
            </activity>
    
        </application>
    
    </manifest>
    package com.example.myapplication;
    
    import java.util.ArrayList;
    import java.util.List;
    
    import android.content.Intent;
    import android.os.Bundle;
    import android.app.Activity;
    import android.util.Log;
    import android.view.Menu;
    import android.view.View;
    import android.widget.CheckBox;
    import android.widget.EditText;
    import android.widget.ListView;
    import android.widget.RadioButton;
    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,ShowActivity.class);
                it1.putExtra("name", name);
                it1.putExtra("password", password);
                final RadioGroup size = (RadioGroup)findViewById(R.id.rg);
                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("mao","羽毛球");
               }
                startActivity(it1);
            }
    }
    package com.example.myapplication;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.util.Log;
    import android.widget.TextView;
    
    public class ShowActivity extends Activity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.showlayout);
    
        }
    
        @Override
        protected void onStart() {
            // TODO Auto-generated method stub
            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 foot=intent.getStringExtra("foot");
            String yumao=intent.getStringExtra("mao");
            String bask=intent.getStringExtra("bask");
            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(foot==null){
                foot="";
            }
            if(bask==null){
                bask="";
            }
            if(yumao==null){
                yumao="";
            }
            if(girl==null)
            {
                girl="";
            }
            if(boy==null){
               boy="";
            }
           c.setText(girl+boy);
            d.setText(foot+bask+yumao);
        }
    }
  • 相关阅读:
    D. Babaei and Birthday Cake--- Codeforces Round #343 (Div. 2)
    Vijos P1389婚礼上的小杉
    AIM Tech Round (Div. 2) C. Graph and String
    HDU 5627Clarke and MST
    bzoj 3332 旧试题
    codeforces 842C Ilya And The Tree
    codesforces 671D Roads in Yusland
    Travelling
    codeforces 606C Sorting Railway Cars
    codeforces 651C Watchmen
  • 原文地址:https://www.cnblogs.com/linshuai3/p/14070699.html
Copyright © 2020-2023  润新知