摘要:今天完成了对APP首页的设计,使用的是侧滑栏功能。完成了在用户登录后获取其信息的功能,并让其显示在用户基础信息的指导位置,包括头像和用户名,方便了后续涉及到的用户功能。另外就是对闹钟功能的有了基本设计及思路,目前只完成了添加闹钟的界面设计,明天再继续完成详细功能。下面是主要代码和截图
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home);
muserOperator = new UserOperator(this);
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);
// LayoutInflater layoutInflater = this.getLayoutInflater();
// view =layoutInflater.inflate(R.layout.home_header,null);
// imageView=(ImageView)view.findViewById(R.id.userimageView);
// textView=(TextView) view.findViewById(R.id.usernameView);
Intent intent = getIntent();//获取Intent对象
String username = intent.getStringExtra("username");
textView=navigationView.getHeaderView(0).findViewById(R.id.usernameView);
imageView=navigationView.getHeaderView(0).findViewById(R.id.userimageView);
User bean = muserOperator.isExit(username);
String userpicture = bean.userpicture;
//Log.d("volley", userpicture);
textView.setText(username);
Bitmap bitmap= BitmapFactory.decodeFile(userpicture);
imageView.setImageBitmap(bitmap);
fm = this.getSupportFragmentManager();
switchFragment("首页");
}