//MainActivity
public class MainActivity extends AppCompatActivity { private int time = 3; Handler handler = new Handler(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //线程 new Thread(){ @Override public void run() { super.run(); while (true){ time--; try { sleep(1000); if (time == 0){ handler.post(new Runnable() { @Override public void run() { Intent intent = new Intent(MainActivity.this, ShouYeActivity.class); startActivity(intent); finish(); } }); } } catch (Exception e) { e.printStackTrace(); } } } }.start(); } }
//ShouYeActivity
public class ShouYeActivity extends AppCompatActivity { private BottomTabBar mb; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_shou_ye); //隐藏原有标题 getSupportActionBar().hide(); //查找控件 mb = (BottomTabBar) findViewById(R.id.bottom_tab_bar); mb.init(getSupportFragmentManager()) .setImgSize(50,50) .setFontSize(8) .setTabPadding(4,6,10) .setChangeColor(Color.RED, Color.DKGRAY) .addTabItem("首页", R.drawable.ac0, Home.class) .addTabItem("分类", R.drawable.abw, Classify.class) .addTabItem("发现", R.drawable.aby, Find.class) .addTabItem("购物车", R.drawable.abu, Cart.class) .addTabItem("我的", R.drawable.ac2, Mine.class) .isShowDivider(false) .setOnTabChangeListener(new BottomTabBar.OnTabChangeListener() { @Override public void onTabChange(int position, String name) { } }); } }
//Home
public class Home extends Fragment{ private View view; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { view = inflater.inflate(R.layout.home, container, false); return view; } }
//二维码的Zxing依赖
compile 'cn.yipianfengye.android:zxing-library:2.1'