我是Android Project的新手。我使用Firebase创建项目。在这个项目中,我想将记录的用户名添加到导航标题中的文本视图中。我用于登录或注册模型选项。但我不能。有人对此有任何经验吗?我的火库数据库数据如下所示。
我想做成这样
我的家庭活动是这样的
package com.cavad.firebaseproject;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
public class Home extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open,
R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView)
findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
Fragment category = new CategoryFragment();
this.setDefaultFragment(category);
}
private void setDefaultFragment(Fragment defaultFragment)
{
this.replaceFragment(defaultFragment);
}
public void replaceFragment(Fragment destFragment)
{
FragmentManager fragmentManager = this.getSupportFragmentManager();
FragmentTransaction fragmentTransaction =
fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.category, destFragment);
fragmentTransaction.commit();
}
BIG阳
狐的传说
蓝山帝景
相关分类