更新时间:2022-02-11 08:08:43
您可以通过您要打开的标签ID,作为您正在创建的 Intent
的附加标签。然后在选项卡式活动
中,假设您使用的是 TabLayout
,则可以执行以下操作-
You can pass the tab id you want to open as an extra to the Intent
you are creating. Then in the tabbed Activity
, assuming you are using TabLayout
, you can do something like this -
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
TabLayout.Tab tab = tabLayout.getTabAt(getIntent().getStringExtra("selected_index"));
tab.select();