From 9bda251c5c23323a4f6c2e6516b9d892edce86e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=9B=9B=E6=B4=81?= <1126388959@qq.com>
Date: Thu, 24 Oct 2019 16:01:08 +0800
Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E4=BE=A7=E6=BB=91=E6=A0=8F=E6=98=BE?=
=?UTF-8?q?=E7=A4=BA=E7=94=A8=E6=88=B7=E5=A7=93=E5=90=8D=E5=92=8C=E8=A7=92?=
=?UTF-8?q?=E8=89=B2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/src/main/AndroidManifest.xml | 2 +-
.../hunnu/sj/raise_money/MainActivity.java | 19 +++++++++++++------
.../{registe.java => RegiteActivity.java} | 2 +-
.../main/java/hunnu/sj/raise_money/User.java | 10 +++++++++-
app/src/main/res/layout/activity_registe.xml | 14 +++++++++++++-
app/src/main/res/layout/nav_header_main.xml | 2 --
6 files changed, 37 insertions(+), 12 deletions(-)
rename app/src/main/java/hunnu/sj/raise_money/{registe.java => RegiteActivity.java} (83%)
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index e5a2278..d556750 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -9,7 +9,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
-
+
diff --git a/app/src/main/java/hunnu/sj/raise_money/MainActivity.java b/app/src/main/java/hunnu/sj/raise_money/MainActivity.java
index c686953..7bb3abd 100644
--- a/app/src/main/java/hunnu/sj/raise_money/MainActivity.java
+++ b/app/src/main/java/hunnu/sj/raise_money/MainActivity.java
@@ -27,19 +27,18 @@ import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private AppBarConfiguration mAppBarConfiguration;
-
+ TextView menu_name;
+ TextView menu_role;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- TextView menu_name = findViewById(R.id.user_name);
- TextView menu_role = findViewById(R.id.user_role);
+
Intent intent = getIntent();
User user;
user = (User) intent.getSerializableExtra("user");
- //menu_name.setText(user.getName());
- //menu_role.setText(user.getPasd());
+
+ setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = findViewById(R.id.fab);
@@ -62,6 +61,14 @@ public class MainActivity extends AppCompatActivity {
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
NavigationUI.setupWithNavController(navigationView, navController);
+
+ if(navigationView.getHeaderCount() > 0) {
+ View header = navigationView.getHeaderView(0);
+ TextView menu_name = header.findViewById(R.id.user_name);
+ TextView menu_role = header.findViewById(R.id.user_role);
+ menu_name.setText(user.getName());
+ menu_role.setText(user.getRole());
+ }
}
@Override
diff --git a/app/src/main/java/hunnu/sj/raise_money/registe.java b/app/src/main/java/hunnu/sj/raise_money/RegiteActivity.java
similarity index 83%
rename from app/src/main/java/hunnu/sj/raise_money/registe.java
rename to app/src/main/java/hunnu/sj/raise_money/RegiteActivity.java
index 4a435fb..3c9c18d 100644
--- a/app/src/main/java/hunnu/sj/raise_money/registe.java
+++ b/app/src/main/java/hunnu/sj/raise_money/RegiteActivity.java
@@ -4,7 +4,7 @@ import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
-public class registe extends AppCompatActivity {
+public class RegiteActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
diff --git a/app/src/main/java/hunnu/sj/raise_money/User.java b/app/src/main/java/hunnu/sj/raise_money/User.java
index 04c97a9..98733e6 100644
--- a/app/src/main/java/hunnu/sj/raise_money/User.java
+++ b/app/src/main/java/hunnu/sj/raise_money/User.java
@@ -5,7 +5,7 @@ import java.io.Serializable;
public class User implements Serializable{
private String name;
private String pasd;
-
+ private String role;
public void setName(String name) {
this.name = name;
}
@@ -21,4 +21,12 @@ public class User implements Serializable{
public String getPasd() {
return pasd;
}
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ public String getRole() {
+ return role;
+ }
}
diff --git a/app/src/main/res/layout/activity_registe.xml b/app/src/main/res/layout/activity_registe.xml
index d65558c..9ec431d 100644
--- a/app/src/main/res/layout/activity_registe.xml
+++ b/app/src/main/res/layout/activity_registe.xml
@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- tools:context=".registe">
+ tools:context=".RegiteActivity">
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/nav_header_main.xml b/app/src/main/res/layout/nav_header_main.xml
index a23e036..971e2bb 100644
--- a/app/src/main/res/layout/nav_header_main.xml
+++ b/app/src/main/res/layout/nav_header_main.xml
@@ -37,7 +37,6 @@
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/fab_margin"
android:paddingTop="@dimen/nav_header_vertical_spacing"
- android:text="@string/menu_name"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textSize="24sp" />
@@ -46,7 +45,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_horizontal_margin"
- android:text="@string/menu_role"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textSize="24sp" />