• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

巷末

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

第三次作业

<?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"
android:background="@mipmap/p20">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#55000000"
android:orientation="vertical"
android:paddingLeft="30dp"
android:paddingRight="30dp" >

<RelativeLayout
android:layout_marginTop="125dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="QQ"
android:drawableLeft="@mipmap/p10"
android:textColor="#fff"
android:layout_centerHorizontal="true"
android:textSize="60dp" />
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="5dp"/>

<EditText
android:id="@+id/userid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:background="@null"
android:hint="QQ号/手机号/邮箱"
android:maxLength="13"
android:singleLine="true"
android:textColor="#fff"
android:textSize="30sp"
android:textColorHint="#eee" />

<TextView
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginTop="10dp"
android:background="#eee" />

<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@null"
android:hint="密码"
android:inputType="textPassword"
android:maxLength="13"
android:singleLine="true"
android:textColor="#fff"
android:textSize="30dp"
android:textColorHint="#eee" />

<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginTop="10dp"
android:background="#eee" />

<Button
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#aaafff"
android:text="登录"
android:textColor="#333fff"
android:textSize="25sp" />
</LinearLayout>
</RelativeLayout>

 

 

 

package com.example.qq123;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
EditText userid;
EditText password;
Button login;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
userid=(EditText)findViewById(R.id.userid);
password=(EditText)findViewById(R.id.password);
login=(Button)findViewById(R.id.login);
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String userid =((EditText)findViewById(R.id.userid)).getText().toString();
String password =((EditText)findViewById(R.id.password)).getText().toString();
if (userid.equals("123456")&&password.equals("123456")) {
Toast t1 = Toast.makeText(getApplicationContext(), "登录成功", Toast.LENGTH_SHORT);
t1.show();
}
else {
Toast t2 = Toast.makeText(getApplicationContext(), "登录失败", Toast.LENGTH_SHORT);
t2.show();
}

}
});
}
}

posted on 2019-09-11 16:10  巷末  阅读(83)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3