欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android?Studio實(shí)現(xiàn)登錄界面功能

 更新時(shí)間:2022年04月23日 11:26:24   作者:落幕·重逢  
這篇文章主要為大家詳細(xì)介紹了Android?Studio實(shí)現(xiàn)登錄界面功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android Studio實(shí)現(xiàn)登錄界面的具體代碼,供大家參考,具體內(nèi)容如下

題目

設(shè)計(jì)一個登錄界面。要求:

a) 包含用戶名、密碼、記住密碼、“忘記密碼”按鈕和“登錄”按鈕。
b) 單擊“忘記密碼”按鈕彈出提示對話框,對話框內(nèi)容自擬。

答案

activity_main.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
? ? xmlns:app="http://schemas.android.com/apk/res-auto"
? ? android:id="@+id/activity_login"
? ? android:layout_width="match_parent"
? ? android:layout_height="match_parent"
? ? >
<RelativeLayout
android:id="@+id/login_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:focusable="true"
android:focusableInTouchMode="true"
? ? >
<RelativeLayout
? ? android:layout_width="match_parent"
? ? android:layout_height="wrap_content"
? ? android:layout_below="@+id/login_edit_pwd"
? ? android:layout_marginTop="20dp"
? ? android:layout_marginBottom="20dp">
? ? <Button
? ? ? ? android:id="@+id/login_btn_login"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_marginLeft="10dp"
? ? ? ? android:layout_marginTop="52dp"
? ? ? ? android:layout_marginRight="50dp"
? ? ? ? android:background="#545bcb"
? ? ? ? android:text="登錄"
? ? ? ? android:textColor="#ffffff"
? ? ? ? android:textSize="20sp"/>
? ? <Button
? ? ? ? android:id="@+id/login_btn_register"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_marginLeft="260dp"
? ? ? ? android:layout_marginTop="52dp"
? ? ? ? android:background="#e52525"
? ? ? ? android:text="注冊"
? ? ? ? android:textColor="#ffffff"
? ? ? ? android:textSize="20sp"/>
</RelativeLayout>

<ImageView
? ? android:layout_width="300dp"
? ? android:layout_height="150dp"
? ? android:id="@+id/logo"
? ? android:layout_alignParentRight="true"
? ? android:layout_alignParentEnd="true"
? ? android:layout_alignParentLeft="true"
? ? android:layout_alignParentStart="true"
? ? android:layout_alignParentTop="true"
? ? android:layout_alignWithParentIfMissing="false"
? ? android:background="#ffffff"
? ? android:src="@drawable/user"/>

<EditText
? ? android:layout_width="400dp"
? ? android:layout_height="60dp"
? ? android:inputType="textPassword"
? ? android:ems="10"
? ? android:id="@+id/login_edit_pwd"
? ? android:drawableLeft="@android:drawable/ic_lock_idle_lock"
? ? android:hint="請輸入您的密碼"
? ? android:layout_below="@+id/login_edit_account"
? ? android:layout_alignParentLeft="true"
? ? android:layout_alignParentStart="true"
? ? />

<EditText
? ? android:layout_width="400dp"
? ? android:layout_height="60dp"
? ? android:inputType="textPersonName"
? ? android:id="@+id/login_edit_account"
? ? android:drawableLeft="@android:drawable/ic_menu_myplaces"
? ? android:hint="請輸入您的用戶名"
? ? android:layout_below="@+id/logo"
? ? android:layout_alignParentLeft="true"
? ? android:layout_alignParentStart="true"
? ? android:layout_marginTop="20dp"
? ? />

<LinearLayout
? ? android:orientation="horizontal"
? ? android:layout_width="match_parent"
? ? android:layout_height="wrap_content"
? ? android:layout_below="@+id/login_edit_pwd"
? ? >

? ? <CheckBox
? ? ? ? android:id="@+id/Login_Remember"
? ? ? ? android:layout_width="200dp"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_marginLeft="10dp"
? ? ? ? android:checked="false"
? ? ? ? android:text="記住密碼"
? ? ? ? android:textSize="15sp"/>
? ? <Button
? ? ? ? android:id="@+id/login_btn_forgetregister"
? ? ? ? android:layout_width="200dp"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_marginRight="0dp"
? ? ? ? android:backgroundTint="#ffffff"
? ? ? ? android:text="忘記密碼"
? ? ? ? android:textColor="@color/black"
? ? ? ? android:textSize="15sp"/>

</LinearLayout>
</RelativeLayout>
</RelativeLayout>

MainActivity.java:

package com.example.myapplication;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AlertDialog;
?import androidx.appcompat.app.AppCompatActivity;
?public class MainActivity extends AppCompatActivity{
? ? ?@Override
? ? ?protected void onCreate(Bundle savedInstanceState){
? ? ? ? super.onCreate(savedInstanceState);
? ? ? ? setContentView(R.layout.activity_main);
? ? ? ? Button button=(Button)findViewById(R.id.login_btn_forgetregister);
? ? ? ? button.setOnClickListener(new View.OnClickListener(){
? ? ? ? ? ? @Override
? ? ? ? ? ? public void onClick(View v){new AlertDialog.Builder(MainActivity.this).setTitle("系統(tǒng)提示").setMessage("請輸入驗(yàn)證信息進(jìn)行驗(yàn)證!")
? ? ? ? ? ? ? ? ? ? .setPositiveButton("確定",new DialogInterface.OnClickListener(){
? ? ? ? ? ? ? ? ? ? ? ? @Override
? ? ? ? ? ? ? ? ? ? ? ? public void onClick(DialogInterface dialog,int which){
? ? ? ? ? ? ? ? ? ? ? ? ? ? finish();
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? }).setNegativeButton("返回",new DialogInterface.OnClickListener(){
? ? ? ? ? ? ? ? ? ? ? ? @Override
? ? ? ? ? ? ? ? ? ? ? ? public void onClick(DialogInterface dialog,int which){
? ? ? ? ? ? ? ? ? ? ? ? }

? ? ? ? }).show();
? ? ? ? }
? ? ? ? });
? ? ? ? Button button1=(Button)findViewById(R.id.login_btn_login);
? ? ? ? button1.setOnClickListener(new View.OnClickListener(){
? ? ? ? ? ? @Override
? ? ? ? ? ? public void onClick(View v){
? ? ? ? ? ? ? ? new AlertDialog.Builder(MainActivity.this).setTitle("系統(tǒng)提示").setMessage("驗(yàn)證成功!")
? ? ? ? .setNegativeButton("確定",new DialogInterface.OnClickListener(){
? ? ? ? ? ? @Override
? ? ? ? ? ? public void onClick(DialogInterface dialog,int which){
? ? ? ? }
? ? ? ? }).show();
? ? ? ? }
? ? ? ? });
? ? ? ? Button button2=(Button)findViewById(R.id.login_btn_register);
? ? ? ? button2.setOnClickListener(new View.OnClickListener(){
? ? ? ? ? ? @Override
? ? ? ? ? ? ? ? ? ? public void onClick(View v){
? ? ? ? new AlertDialog.Builder(MainActivity.this).setTitle("系統(tǒng)提示").setMessage("注冊成功!")
? ? ? ? .setNegativeButton("確定",new DialogInterface.OnClickListener(){
? ? ? ? ? ? @Override
? ? ? ? ? ? public void onClick(DialogInterface dialog,int which){
? ? ? ? }
? ? ? ? }).show();
? ? ? ? }
? ? ? ? });
? ?}
}

運(yùn)行結(jié)果

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論