0
我想用一個抽屜本次活動如何添加片段主要活動
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener, ActionBar.TabListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
//codi
}
*但我在這個活動中使用抽屜* ...所以?這是如何阻止顯示片段的? –
我不能'在主要活動中使用擴展片段,我知道如何調用片段 – Mouna14
您是否嘗試閱讀一些教程?另外,我認爲Android Studio創建的「NavigationView」模板包含Fragments。 –