| | |
| | | package cn.com.basic.face.base; |
| | | |
| | | import android.content.Context; |
| | | import android.os.Handler; |
| | | import android.support.design.widget.TabLayout; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.app.FragmentManager; |
| | |
| | | import android.os.Bundle; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.Window; |
| | | import android.view.WindowManager; |
| | | import android.widget.ImageView; |
| | | import android.widget.TextView; |
| | | import android.widget.Toast; |
| | | |
| | | import com.bsk.zhangbo.demoforbsk.R; |
| | | import cn.com.basic.face.fragment.SurveillanceFragment; |
| | |
| | | myFragmentPagerAdapter.addFragment(PhoneCallFragment.getInstance(), tabNamesList.get(3),tabIcons[3]); |
| | | myFragmentPagerAdapter.addFragment(VisitFragment.getInstance(), tabNamesList.get(4),tabIcons[4]); |
| | | myFragmentPagerAdapter.addFragment(AttendanceFragment.getInstance(), tabNamesList.get(5),tabIcons[5]); |
| | | myFragmentPagerAdapter.addFragment(DeviceFragment.newInstance(), tabNamesList.get(6),tabIcons[6]); |
| | | myFragmentPagerAdapter.addFragment(DeviceFragment.getInstance(), tabNamesList.get(6),tabIcons[6]); |
| | | mViewPager.setAdapter(myFragmentPagerAdapter); |
| | | mViewPager.setOffscreenPageLimit(6);//viewpager缓存个数 |
| | | mTabLayout.setupWithViewPager(mViewPager); |
| | |
| | | tab.getCustomView().setSelected(true); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | public static MainActivity getInstance() { |
| | |
| | | |
| | | } |
| | | |
| | | boolean doubleBackToExitPressedOnce = false; |
| | | |
| | | @Override |
| | | public void onBackPressed() { |
| | | if (doubleBackToExitPressedOnce) { |
| | | super.onBackPressed(); |
| | | return; |
| | | } |
| | | |
| | | this.doubleBackToExitPressedOnce = true; |
| | | Toast.makeText(this, "请再次按返回键退出", Toast.LENGTH_SHORT).show(); |
| | | |
| | | new Handler().postDelayed(new Runnable() { |
| | | |
| | | @Override |
| | | public void run() { |
| | | doubleBackToExitPressedOnce=false; |
| | | } |
| | | }, 2000); |
| | | } |
| | | |
| | | } |