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"> + +