Android中實(shí)現(xiàn)頁面切換的方法有多種,以下是常用的幾種方法:
Intent intent = new Intent(CurrentActivity.this, TargetActivity.class);
startActivity(intent);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.container, new TargetFragment());
transaction.commit();
ViewPager viewPager = findViewById(R.id.viewPager);
viewPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager()));
viewPager.setCurrentItem(1); // 切換到第二個頁面
Intent intent = new Intent(CurrentActivity.this, TargetActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
以上是常用的幾種實(shí)現(xiàn)Android頁面切換的方法,根據(jù)具體的需求和場景選擇不同的方法來實(shí)現(xiàn)頁面切換效果。