2020.10.1

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

    tools:context=".MainActivity"

    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="200dp"
        >
        <EditText
            android:id="@+id/etiname"
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="40dp"
            android:hint="输入用户名"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="用户名"
            android:textSize="28dp"
            android:layout_marginLeft="40dp"
            />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="20dp"
        >
        <EditText
            android:id="@+id/edimima"
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="40dp"
            android:hint="输入密码"
            />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="40dp"
            android:text="密码"
            android:textSize="28dp"
            />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:layout_marginTop="80dp"
        >

        <Button
            android:id="@+id/btn_one"
            android:layout_marginLeft="100dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="登陆"
            android:onClick="onclick2"
            tools:ignore="OnClick" />

    </LinearLayout>

</LinearLayout>

package com.example.myapplication1;

import androidx.appcompat.app.AppCompatActivity;

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

public class MainActivity extends AppCompatActivity implements View.OnClickListener{
   private Button btn_one;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setContentView(R.layout.activity_main);
        btn_one =(Button)findViewById(R.id.btn_one);

        btn_one.setOnClickListener(new  View.OnClickListener(){
            public void onClick(View View){
                btn_one.setText("按钮被点击");
            }
        })
    }
}

 

posted @ 2020-12-06 13:45  我的白菜  阅读(73)  评论(0)    收藏  举报