// tabview的点击效果 切换逻辑 @Override public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.main_tab01: changeItem(0); vp.setCurrentItem(0); toolbar_title_main.setText("八字排盘"); icon_menu.setImageResource(R.drawable.icon_menu); showmenu = true; betterpager(); break; case R.id.main_tab02: changeItem(1); vp.setCurrentItem(1); toolbar_title_main.setText("八字先生"); icon_menu.setImageResource(R.drawable.menu_search); showmenu = false; betterpager(); break; case R.id.main_tab03: changeItem(2); vp.setCurrentItem(2); toolbar_title_main.setText("江湖"); icon_menu.setImageResource(R.drawable.menu_search); showmenu = false; list_frags.clear(); initDatas(); myadapter.setDatas(list_frags); break; case R.id.main_tab04: changeItem(3); vp.setCurrentItem(3); toolbar_title_main.setText("个人中心"); icon_menu.setImageResource(R.drawable.icon_menu); showmenu = true; list_frags.clear(); initDatas(); myadapter.setDatas(list_frags); break; default: break; } }
// fragmentpageradapter优化 public void betterpager() { list_frags.clear(); initDatas(); myadapter.setDatas(list_frags); }