0
我希望在应用程序启动后显示homefragment,意思是在menuitem被点击之前,我应该在哪里放置片段事务?谢谢!在哪里放碎片交易?
public boolean onOptionsItemSelected(MenuItem item) {
// The action bar home/up action should open or close the drawer.
// ActionBarDrawerToggle will take care of this.
switch(item.getItemId()){
case android.R.id.home:
if(mDrawerLayout.isDrawerOpen(leftDrawerLayout)){
mDrawerLayout.closeDrawer(leftDrawerLayout);
} else {
mDrawerLayout.openDrawer(leftDrawerLayout);
}
case R.id.home:
Toast.makeText(getApplicationContext(), "home", Toast.LENGTH_LONG).show();
**ft.replace(R.id.content_frame, homefragment);**
break;
case R.id.feed:
Toast.makeText(getApplicationContext(), "feed", Toast.LENGTH_LONG).show();
ft.replace(R.id.content_frame, feedfragment);
break;
}
ft.commit();
return super.onOptionsItemSelected(item);
}
感谢。我设法解决这个问题。 – user3184395