第三周作业

1.创建3个界面

第一个界面有3个button

第二个界面有单选按钮 学历:初中 高中 专科 本科

第三个界面有5个复选框  学过哪些课程

Java

Ios

Android

Html

Jsp

把第二个界面设置为启动界面

<?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">
    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/btn_1"
        android:textColor="#00FFEE"
        android:layout_margin="15dp"
        android:text="按钮一"></Button>
    <Button
        android:id="@+id/botton2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/btn_1"
        android:textColor="#00FFEE"
        android:layout_below="@id/button1"
        android:layout_margin="15dp"
        android:text="按钮二"></Button>
    <Button
        android:id="@+id/botton3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/btn_1"
        android:textColor="#00FFEE"
        android:layout_below="@id/botton2"
        android:layout_margin="15dp"
        android:text="按钮三"></Button>
</RelativeLayout>

 

 

<?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/v_1"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:text="你的学历是?"
        android:textSize="10pt"></TextView>

    <RadioButton
        android:id="@+id/rb_1"
        android:layout_width="200dp"
        android:layout_height="30dp"
        android:text="初中"
        android:textSize="10pt"
        />

    <RadioButton
        android:id="@+id/rb_2"
        android:layout_width="200dp"
        android:layout_height="30dp"
        android:text="高中"
        android:textSize="10pt"
         />

    <RadioButton
        android:id="@+id/rb_3"
        android:layout_width="200dp"
        android:layout_height="30dp"
        android:text="专科"
        android:textSize="10pt"
         />

    <RadioButton
        android:id="@+id/rb_4"
        android:layout_width="200dp"
        android:layout_height="30dp"
        android:text="本科"
        android:checked="true"
        android:textSize="10pt"
         />

</LinearLayout>

 

 

<?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:layout_width="match_parent"
        android:layout_height="60dp"
        android:text="你学过哪些课程?"
        android:textSize="15pt"></TextView>

    <CheckBox
        android:layout_width="100dp"
        android:layout_height="50dp"
        android:text="java"/>

    <CheckBox
        android:layout_width="100dp"
        android:layout_height="50dp"
        android:text="ios" />

    <CheckBox
        android:layout_width="100dp"
        android:layout_height="50dp"
        android:text="Android"
         />

    <CheckBox
        android:layout_width="100dp"
        android:layout_height="50dp"
        android:text="Html"
         />

    <CheckBox
        android:layout_width="100dp"
        android:layout_height="50dp"
        android:text="Jsp"
        />
</LinearLayout>

 

 

2.在界面1上设置按钮点击事件

按钮1用onclick方式

按钮2和按钮3用监听方式

点击后用Toast弹出 按钮xxx被点击。

<?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">
    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/btn_1"
        android:textColor="#00FFEE"
        android:layout_margin="15dp"
        android:text="按钮一"
        android:onClick="click1"></Button>
    <Button
        android:id="@+id/botton2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/btn_1"
        android:textColor="#00FFEE"
        android:layout_below="@id/button1"
        android:layout_margin="15dp"
        android:text="按钮二"></Button>
    <Button
        android:id="@+id/botton3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/btn_1"
        android:textColor="#00FFEE"
        android:layout_below="@id/botton2"
        android:layout_margin="15dp"
        android:text="按钮三"></Button>
</LinearLayout>
package itcast.cn;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class ToastActivity extends AppCompatActivity {
    private Button btn1;
    private Button btn2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_toast);
        btn1=findViewById(R.id.botton2);
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(ToastActivity.this,"按钮二被点击",Toast.LENGTH_LONG).show();
            }
        });
        btn2=findViewById(R.id.botton3);
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(ToastActivity.this,"按钮三被点击",Toast.LENGTH_LONG).show();
            }
        });
    }
    public  void  click1(View view){
        Toast.makeText(this,"按钮一被点击",Toast.LENGTH_LONG).show();
    }

}

 

 3.设计布局界面

<?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">

    <ImageButton
        android:id="@+id/v_1"
        android:layout_width="300dp"
        android:layout_height="150dp"
        android:layout_gravity="center_horizontal"
        android:layout_centerInParent="true"
        android:background="#FFFFFF"
        android:src="@drawable/image"></ImageButton>

    <EditText
        android:id="@+id/v_2"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:hint="                        请输入手机号/邮箱"
        android:maxLines="2"
        android:textColor="#000000"
        android:textSize="20sp"></EditText>

    <EditText
        android:id="@+id/v_3"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:hint="                               请输入密码"
        android:textColor="#000000"
        android:textSize="20sp"
        android:drawableRight="@drawable/see"></EditText>

    <Button
        android:id="@+id/btn_1"
        android:layout_width="300dp"
        android:layout_height="60dp"
        android:layout_below="@id/v_3"
        android:background="@drawable/btn_1"
        android:text="登录"
        android:layout_gravity="center"
        android:layout_marginTop="30dp"
        android:textColor="#FFFFFF"></Button>

    <Button
        android:id="@+id/btn_3"
        android:layout_width="300dp"
        android:layout_height="60dp"
        android:background="@drawable/btn_3"
        android:layout_gravity="center"
        android:textColor="#FFFFFF"
        android:layout_below="@id/v_3"
        android:layout_marginTop="20dp"
        android:text="不注册,跳过登录"></Button>

    <TextView
        android:id="@+id/v_4"
        android:layout_width="100dp"
        android:layout_height="50dp"
        android:text="注册账号"
        android:layout_gravity="left"
        android:layout_marginTop="15dp"
        android:textSize="20sp">
    </TextView>
    <TextView
        android:id="@+id/v_5"
        android:layout_width="100dp"
        android:layout_height="50dp"
        android:layout_marginTop="-50dp"
        android:text="忘记密码"
        android:layout_gravity="right"
        android:textSize="20dp">

    </TextView>
    <ImageButton
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:src="@drawable/we2"
        android:background="#FFFFFF"
        android:layout_marginLeft="50dp"></ImageButton>

    <ImageButton
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_marginLeft="10dp"
        android:background="#FFFFFF"
        android:layout_gravity="center"
        android:layout_marginTop="-100dp"
        android:src="@drawable/apple"></ImageButton>

    <ImageButton
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:src="@drawable/qq"
        android:background="#FFFFFF"
        android:layout_gravity="right"
        android:layout_marginRight="30dp"
        android:layout_marginTop="-103dp"></ImageButton>

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="60dp"
        android:layout_marginTop="0dp"
        android:text="已阅读并同意                    和"
        android:textColor="#000000"></CheckBox>

    <TextView
        android:layout_width="90dp"
        android:layout_height="20dp"
        android:text="《用户协议》"
        android:textColor="#FF0000"
        android:layout_marginLeft="170dp"
        android:layout_marginTop="-25dp"></TextView>
    <TextView
        android:layout_width="90dp"
        android:layout_height="20dp"
        android:text="《隐私政策》"
        android:textColor="#FF0000"
        android:layout_marginLeft="260dp"
        android:layout_marginTop="-21dp"></TextView>
</LinearLayout>

 

posted @ 2021-09-03 20:35  计算机1904李傲  阅读(23)  评论(0编辑  收藏  举报