小視訊app原始碼,實現簡單的登入介面,輸入賬號密碼

zhibo系統開發發表於2021-11-19

小視訊app原始碼,實現簡單的登入介面,輸入賬號密碼實現的相關程式碼

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="
    xmlns:app="
    xmlns:tools="
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity"
    android:background="@drawable/這邊自己加圖片,圖片放左側drawable"
    android:alpha="0.9"
    >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="254dp"
            android:orientation="vertical"
            android:gravity="center"
            >
            <EditText
                android:id="@+id/name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ems="10"
                android:hint="使用者名稱"
                android:inputType="textPersonName" />
            <EditText
                android:id="@+id/pass"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ems="10"
                android:hint="密碼"
                android:inputType="textPersonName" />
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal"
                android:gravity="center"
                >
                <Button
                    android:id="@+id/button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:hint="登入"
                    />
                <Button
                    android:id="@+id/button2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="忘記密碼" />
            </LinearLayout>
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            >
        </LinearLayout>
    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
//登入驗證程式碼
    @Override
    public void  onClick(View v) {
        //    通過AlertDialog.Builder這個類來例項化我們的一個AlertDialog的物件
        AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
        //    設定Title的圖示
        builder.setIcon(R.drawable.這邊自己加圖片,圖片放左側drawable);
        //    設定Title的內容
        String mname = "賬號";
        String mpass = "密碼";
        String user = name.getText().toString().trim();
        String pwd = pass.getText().toString().trim();
        if (user.equals(mname) && pwd.equals(mpass)) {
            Toast.makeText(this, "登入成功", Toast.LENGTH_SHORT).show();
            builder.setTitle("登入成功");
            builder.show(); //    顯示出該對話方塊
        } else {
            Toast.makeText(this, "您的輸入有誤,請重試", Toast.LENGTH_SHORT).show();
            builder.setTitle("您的輸入有誤,請重試");
            builder.show(); //    顯示出該對話方塊
        }
    }


以上就是小視訊app原始碼,實現簡單的登入介面,輸入賬號密碼實現的相關程式碼, 更多內容歡迎關注之後的文章


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2843091/,如需轉載,請註明出處,否則將追究法律責任。

相關文章