List of usage examples for android.app ActionBar setHomeButtonEnabled
public void setHomeButtonEnabled(boolean enabled)
From source file:com.commonsware.cwac.cam2.support.CameraFragment.java
@Override public void onHiddenChanged(boolean isHidden) { super.onHiddenChanged(isHidden); if (!isHidden) { ActionBar ab = getActivity().getActionBar(); ab.setBackgroundDrawable(/*w w w. j av a 2 s . c o m*/ getActivity().getResources().getDrawable(R.drawable.cwac_cam2_action_bar_bg_transparent)); ab.setTitle(""); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ab.setDisplayHomeAsUpEnabled(false); } else { ab.setDisplayShowHomeEnabled(false); ab.setHomeButtonEnabled(false); } } }
From source file:com.commonsware.cwac.cam2.support.ConfirmationFragment.java
@Override public void onHiddenChanged(boolean isHidden) { super.onHiddenChanged(isHidden); if (!isHidden) { ActionBar ab = getActivity().getActionBar(); ab.setBackgroundDrawable(/* ww w. jav a 2 s . c o m*/ getActivity().getResources().getDrawable(R.drawable.cwac_cam2_action_bar_bg_translucent)); ab.setTitle(""); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ab.setDisplayHomeAsUpEnabled(true); ab.setHomeAsUpIndicator(R.drawable.cwac_cam2_ic_close_white); } else { ab.setIcon(R.drawable.cwac_cam2_ic_close_white); ab.setDisplayShowHomeEnabled(true); ab.setHomeButtonEnabled(true); } } }
From source file:it.durip_app.MACActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mac); data = new MACSource(); isIperfRunning = isIperfRunning();/* w w w. j av a 2 s .co m*/ isOlsrRunning = isOlsrRunning(); // Get the message from the intent Intent intent = getIntent(); paramUrl = intent.getStringExtra(MainActivity.PARAM_URL); paramT = intent.getIntExtra(MainActivity.PARAM_T, 200); paramI = intent.getIntExtra(MainActivity.PARAM_I, 5); paramMAC = intent.getStringExtra(MainActivity.PARAM_MAC); paramSleep = intent.getIntExtra(MainActivity.PARAM_SLEEP, 500); paramPort = intent.getIntExtra(MainActivity.PARAM_PORT, 4000); paramVerbose = intent.getIntExtra(MainActivity.PARAM_VERBOSE, 1); data.setUrl(paramUrl); data.setT(paramT); data.setI(paramI); data.setPort(paramPort); data.setSleep(paramSleep); data.setVerbose(paramVerbose); data.setMAC(paramMAC); // kick off the data generating thread: //mySource = new Thread(data); //mySource.start(); data.startMAC(); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent. actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by the adapter. // Also specify this Activity object, which implements the TabListener interface, as the // listener for when this tab is selected. actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } // Show the Up button in the action bar. }
From source file:org.ounl.lifelonglearninghub.nfcecology.fcube.navigate.SwipeFragmentActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pager); // Create the adapter that will return a fragment for each of the three // primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Actvate home button final ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(true); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener // for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override/* www . ja v a2s. c o m*/ public void onPageSelected(int position) { // When swiping between different app sections, select // the corresponding tab. // We can also use ActionBar.Tab#select() to do this if // we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. // Also specify this Activity object, which implements the // TabListener interface, as the // listener for when this tab is selected. actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.af.synapse.MainActivity.java
@SuppressWarnings("ConstantConditions") private void continueCreate() { View v = LayoutInflater.from(this).inflate(R.layout.activity_main, null); mViewPager = (ViewPager) v.findViewById(R.id.mainPager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPagerPageChangeListener()); mDrawerList = (ListView) v.findViewById(R.id.left_drawer); String[] section_titles = new String[Utils.configSections.size()]; for (int i = 0; i < Utils.configSections.size(); i++) section_titles[i] = Utils.localise(((JSONObject) Utils.configSections.get(i)).get("name")); mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_item, section_titles)); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); mDrawerList.setItemChecked(0, true); mDrawerLayout = (DrawerLayout) v.findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close);//from ww w. j a va2 s . c om mDrawerLayout.setDrawerListener(mDrawerToggle); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); mDrawerToggle.syncState(); ActionValueUpdater.refreshButtons(true); for (TabSectionFragment f : fragments) f.onElementsMainStart(); setContentView(v); actionBar.show(); Utils.appStarted = true; setPaddingDimensions(); L.i("Interface creation finished in " + (System.nanoTime() - startTime) + "ns"); if (Utils.appStarted) this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); if (!BootService.getBootFlag() && !BootService.getBootFlagPending()) { new AlertDialog.Builder(this).setTitle(R.string.popup_failed_boot_title) .setMessage(R.string.popup_failed_boot_message).setCancelable(true) .setPositiveButton(R.string.popup_failed_boot_ack, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } }
From source file:com.example.jenil.parsedemo.GamePlayActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_ACTION_BAR); setContentView(R.layout.activity_game_play); Intent intent = getIntent();//from w w w. ja va 2s. com Phrase = intent.getStringExtra("MOVIE"); words = Phrase.split(" "); opponent = intent.getStringExtra("OPPONENT"); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); if (actionBar == null) { Log.i("ALERT", "NULL"); } else { Log.i("ALERT", "NOT NULL"); } // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent. actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount() - 1; i++) { // Create a tab with text corresponding to the page title defined by the adapter. // Also specify this Activity object, which implements the TabListener interface, as the // listener for when this tab is selected. actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } actionBar.addTab(actionBar.newTab().setText("Submit").setTabListener(this)); }
From source file:com.cachirulop.moneybox.activity.MovementDetailActivity.java
/** * Initialize the activity action bar// w ww. ja v a 2s . c o m */ private void createActionBar() { final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); }
From source file:com.denel.facepatrol.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mycontext = getApplicationContext(); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent.//from w w w . j av a 2 s . c o m actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by the adapter. // Also specify this Activity object, which implements the TabListener interface, as the // listener for when this tab is selected. actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:de.da_sense.moses.client.WelcomeActivity.java
@Override public void onCreate(Bundle savedInstanceState) { Log.d(LOG_TAG, "onCreate() called"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); thisInstance = this; mAppSectionsPagerAdapter = new WelcomeActivityPagerAdapter(getSupportFragmentManager(), this); // get ActionBar and set NavigationMode final ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override// w w w .j ava 2 s . c o m public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. // Also specify this Activity object, which implements the // TabListener interface, as the // listener for when this tab is selected. actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } // Moses got called to view a UserStudy boolean isShowUserStudyCall = getIntent() .getStringExtra(ViewUserStudyActivity.EXTRA_USER_STUDY_APK_ID) != null; if (isShowUserStudyCall) { onLoginCompleteShowUserStudy = getIntent() .getStringExtra(ViewUserStudyActivity.EXTRA_USER_STUDY_APK_ID); } if (!isLoginInformationComplete(this) && !waitingForResult) { // Here, the activity is called to display the login screen, and, // when filled in, redirect the user to the user study that was // meant to be displayed originally waitingForResult = true; // set flag that on login credentials arrival show a user study // set the deviceID in the SharedPreferences before attempting to // login String theDeviceID = Secure.getString(getContentResolver(), Secure.ANDROID_ID); PreferenceManager.getDefaultSharedPreferences(this).edit() .putString(MosesPreferences.PREF_DEVICEID, theDeviceID).commit(); Intent loginDialog = new Intent(WelcomeActivity.this, LoginActivity.class); startActivityForResult(loginDialog, 1); } if (HistoryExternalApplicationsManager.getInstance() == null) { HistoryExternalApplicationsManager.init(this); } if (InstalledExternalApplicationsManager.getInstance() == null) { InstalledExternalApplicationsManager.init(this); } if (UserstudyNotificationManager.getInstance() == null) { UserstudyNotificationManager.init(this); } // initialize the UI elements initControls(savedInstanceState); }