@Override public boolean onNavigationItemSelected(int position, long id) { if (position == 0) { if (std == null) { std = DemoCameraFragment.newInstance(false); } current = std; } else { if (ffc == null) { ffc = DemoCameraFragment.newInstance(true); } current = ffc; } getFragmentManager().beginTransaction().replace(R.id.container, current).commit(); findViewById(android.R.id.content) .post( new Runnable() { @Override public void run() { current.lockToLandscape(isLockedToLandscape); } }); return (true); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (hasTwoCameras) { final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( actionBar.getThemedContext(), R.array.nav, android.R.layout.simple_list_item_1); actionBar.setListNavigationCallbacks(adapter, this); } else { current = DemoCameraFragment.newInstance(false); getFragmentManager().beginTransaction().replace(R.id.container, current).commit(); } }