Prechádzať zdrojové kódy

登录页

Signed-off-by: duanchangpeng <838560574@qq.com>
duanchangpeng 5 rokov pred
rodič
commit
0c8cdb2cdd

+ 1 - 0
app/src/main/AndroidManifest.xml

@@ -33,6 +33,7 @@
         <activity android:name=".ui.activity.MainActivity" />
         <activity android:name=".ui.activity.SearchActivity" />
         <activity android:name=".ui.activity.ViewPageActivity" />
+        <activity android:name=".ui.activity.LoginActivity" />
     </application>
 
 </manifest>

+ 26 - 0
app/src/main/java/com/example/watch/ui/activity/LoginActivity.kt

@@ -0,0 +1,26 @@
+package com.example.watch.ui.activity
+
+import android.content.Intent
+import android.os.Bundle
+import android.view.View
+import android.widget.Button
+import android.widget.Toast
+import androidx.appcompat.app.AppCompatActivity
+import com.example.watch.R
+
+class LoginActivity : AppCompatActivity(), View.OnClickListener {
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+        setContentView(R.layout.login_layout)
+        val ButtonLogin = findViewById<Button>(R.id.go_on)
+        ButtonLogin.setOnClickListener(this)
+    }
+
+    override fun onClick(v: View?) {
+        Toast.makeText(this, "点击了", Toast.LENGTH_SHORT).show()
+    }
+
+
+}
+
+

+ 24 - 9
app/src/main/java/com/example/watch/ui/activity/MainActivity.kt

@@ -11,16 +11,11 @@ class MainActivity : AppCompatActivity() {
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
 
-        val sharedPreferences = getSharedPreferences("FirstRun", 0)
-        val first_run = sharedPreferences.getBoolean("First", true)
-        if (first_run) {
-            sharedPreferences.edit().putBoolean("First", false).commit()
-            val ViewPageActivityIntent = Intent(this, ViewPageActivity::class.java)
-            startActivity(ViewPageActivityIntent)
-        } else {
-            setContentView(R.layout.activity_main)
-        }
+//        首次加载
+        FirstRun()
 
+//        登录判断
+        login()
 
 
 //        点击按钮Toast
@@ -61,4 +56,24 @@ class MainActivity : AppCompatActivity() {
 
     }
 
+    private fun login(){
+        //        val login = 1
+//        if(login == 1){
+//            val LoginActivityIntent = Intent(this, LoginActivity::class.java)
+//            startActivity(LoginActivityIntent)
+//        }
+    }
+
+    private fun FirstRun(){
+        val sharedPreferences = getSharedPreferences("FirstRun", 0)
+        val first_run = sharedPreferences.getBoolean("First", true)
+        if (first_run) {
+            sharedPreferences.edit().putBoolean("First", false).commit()
+            val ViewPageActivityIntent = Intent(this, ViewPageActivity::class.java)
+            startActivity(ViewPageActivityIntent)
+        } else {
+            setContentView(R.layout.activity_main)
+        }
+    }
+
 }

BIN
app/src/main/res/drawable/login.png


BIN
app/src/main/res/drawable/login_button.png


+ 55 - 0
app/src/main/res/layout/login_layout.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical"
+        tools:layout_editor_absoluteX="86dp"
+        tools:layout_editor_absoluteY="168dp"
+        android:background="@drawable/login"
+        >
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="221dp"
+            android:layout_marginTop="250dp"
+            android:layout_weight="1"
+            android:orientation="vertical">
+
+            <EditText
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:hint="@string/account"
+                android:inputType="text"
+                android:selectAllOnFocus="true"
+                android:singleLine="true"
+                android:textColorHint="#ccc"
+                android:textColor="#000"
+                android:textScaleX="1"
+                android:layout_marginLeft="20dp"
+                android:layout_marginRight="20dp"/>
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_weight="2"
+            android:gravity="right"
+            android:orientation="vertical">
+
+            <Button
+                android:id="@+id/go_on"
+                android:layout_width="100dp"
+                android:layout_height="48dp"
+                android:background="@drawable/login_button"
+                android:onClick="go_on_click"
+                android:text="@string/go_on"
+                tools:ignore="OnClick" />
+        </LinearLayout>
+    </LinearLayout>
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 0 - 5
app/src/main/res/menu/bottom_nav_menu.xml

@@ -6,11 +6,6 @@
         android:icon="@drawable/band"
         android:title="@string/title_band" />
 
-    <item
-        android:id="@+id/navigation_second"
-        android:icon="@drawable/rank"
-        android:title="@string/title_rank" />
-
     <item
         android:id="@+id/navigation_notifications"
         android:icon="@drawable/statis"

+ 3 - 1
app/src/main/res/values/strings.xml

@@ -1,5 +1,5 @@
 <resources>
-    <string name="app_name">watch</string>
+    <string name="app_name">小飞龙</string>
     <string name="title_home">Home</string>
     <string name="title_dashboard">Dashboard</string>
     <string name="title_notifications">Notifications</string>
@@ -8,4 +8,6 @@
     <string name="title_statis">运动统计</string>
     <string name="app_version">1.0.0</string>
     <string name="enter_main">进入主页</string>
+    <string name="go_on">继续</string>
+    <string name="account">请输入手机号</string>
 </resources>