zoukankan      html  css  js  c++  java
  • 第六周

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.login1">
    
        <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">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <activity android:name=".secondActivity"/>
        </application>
    
    </manifest>
    package com.example.login1;
    
    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.login1.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
            intent.setClass(MainActivity.this,secondActivity.class);
    
    
    
            //为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);
    
    package com.example.login1;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.widget.EditText;
    import android.widget.TextView;
    
    import com.example.login1.R;
    
    public class secondActivity extends Activity {
    
        public void startActivity(Intent intent){
    
        }
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.news);
            TextView show_name = (TextView)findViewById(R.id.show_name);
            TextView show_pass =(TextView)findViewById(R.id.show_pass);
            TextView show_gender = (TextView)findViewById(R.id.show_gender);
            TextView show_hobby =(TextView)findViewById(R.id.show_hobby);
            Intent intent = getIntent();
            Bundle bundle = getIntent().getExtras();
            show_name.setText(bundle.getString("name"));
            show_pass.setText(bundle.getString("password"));
            show_gender.setText(intent.getStringExtra("gender"));
            show_hobby.setText(intent.getStringExtra("hobbys"));
    
        }
    
        public void finish(){
    
        }
    }
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
        <TextView
            android:id="@+id/textView2"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:background="#00BCD4"
            android:gravity="center"
            android:text="注册信息"
            android:textColor="#FF5722"
            android:textSize="25sp" />
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="25dp"
            android:gravity="center"
            android:orientation="vertical">
    
            <TextView
                android:id="@+id/textView3"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="你的注册信息是:"
                android:textSize="20sp" />
    
            <TableLayout
                android:layout_width="match_parent"
                android:layout_height="400dp">
    
                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
    
                    <TextView
                        android:id="@+id/textView4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="用户名:"
                        android:textSize="20sp" />
    
                    <TextView
                        android:id="@+id/show_name"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />
                </TableRow>
    
                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
    
                    <TextView
                        android:id="@+id/textView9"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        
     
  • 相关阅读:
    Docker的安装和配置
    SpringBoot如何添加拦截器
    使用Java执行python代码并得到结果
    Redis高可用集群之水平扩展
    Redis集群演变和集群部署
    Redis核心原理
    Redis基本数据结构
    Redis安装和配置
    Typora+PicGo+Gitee笔记方案
    视频描述(Video Captioning)近年重要论文总结
  • 原文地址:https://www.cnblogs.com/wzm7282/p/14100099.html
Copyright © 2011-2022 走看看