List of usage examples for android.app ActionBar.Tab setIcon
public abstract void setIcon(Drawable icon);
From source file:transapps.gpxfitness.ui.MainActivity.java
@Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { tab.setIcon(mAppSectionsPagerAdapter.getPageIconUnselected(tab.getPosition())); }
From source file:com.xenon.greenup.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // 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); //Set the stacked background otherwise we get the gross dark gray color under the icon BitmapDrawable background = (BitmapDrawable) getResources().getDrawable(R.drawable.bottom_menu); background.setTileModeXY(TileMode.REPEAT, TileMode.MIRROR); actionBar.setStackedBackgroundDrawable(background); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setIcon(R.drawable.bottom_menu); _ViewPager = (ViewPager) findViewById(R.id.pager); mTabsAdapter = new TabsAdapter(this, _ViewPager); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < 3; 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.Tab tabToAdd = actionBar.newTab(); if (i == 0) //Set the home page as active since we'll start there: tabToAdd.setIcon(getActiveIcon(i)); else/* w ww . j a v a 2s. c o m*/ tabToAdd.setIcon(getRegularIcon(i)); mTabsAdapter.addTab(tabToAdd); } //Setting the display to custom will push the action bar to the top //which gives us more real estate actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.show(); Log.i("visible", "" + _ViewPager.VISIBLE); }
From source file:transapps.gpxfitness.ui.MainActivity.java
@Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { // When the given tab is selected, switch to the corresponding page in the ViewPager. mViewPager.setCurrentItem(tab.getPosition()); tab.setIcon(mAppSectionsPagerAdapter.getPageIconSelected(tab.getPosition())); }
From source file:com.nks.nksmod.otaupdater.OTAUpdaterActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Context context = getApplicationContext(); cfg = Config.getInstance(context);/*from ww w.ja va2 s . c o m*/ final int MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 0; if (ContextCompat.checkSelfPermission(OTAUpdaterActivity.this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.shouldShowRequestPermissionRationale(OTAUpdaterActivity.this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.alert_permission_storage); builder.setMessage(R.string.alert_permission_storage_message); builder.setCancelable(false); builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); builder.setNeutralButton(R.string.enable_permission, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); ActivityCompat.requestPermissions(OTAUpdaterActivity.this, new String[] { android.Manifest.permission.WRITE_EXTERNAL_STORAGE }, MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE); } }); final AlertDialog dlg = builder.create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { onDialogShown(dlg); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { onDialogClosed(dlg); } }); dlg.show(); } else { ActivityCompat.requestPermissions(OTAUpdaterActivity.this, new String[] { android.Manifest.permission.WRITE_EXTERNAL_STORAGE }, MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE); if (ActivityCompat.shouldShowRequestPermissionRationale(OTAUpdaterActivity.this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.alert_permission_storage); builder.setMessage(R.string.alert_permission_storage_message); builder.setCancelable(false); builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); final AlertDialog dlg = builder.create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { onDialogShown(dlg); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { onDialogClosed(dlg); } }); dlg.show(); } } } boolean data = Utils.dataAvailable(this); boolean wifi = Utils.wifiConnected(this); if (!data || !wifi) { final boolean nodata = !data && !wifi; if ((nodata && !cfg.getIgnoredDataWarn()) || (!nodata && !cfg.getIgnoredWifiWarn())) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(nodata ? R.string.alert_nodata_title : R.string.alert_nowifi_title); builder.setMessage(nodata ? R.string.alert_nodata_message : R.string.alert_nowifi_message); builder.setCancelable(false); builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); builder.setNeutralButton(R.string.alert_wifi_settings, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Intent i = new Intent(Settings.ACTION_WIFI_SETTINGS); startActivity(i); } }); builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (nodata) { cfg.setIgnoredDataWarn(true); } else { cfg.setIgnoredWifiWarn(true); } dialog.dismiss(); } }); final AlertDialog dlg = builder.create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { onDialogShown(dlg); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { onDialogClosed(dlg); } }); dlg.show(); } } Utils.updateDeviceRegistration(this); CheckinReceiver.setDailyAlarm(this); setContentView(R.layout.main); ViewPager mViewPager = (ViewPager) findViewById(R.id.pager); bar = getActionBar(); assert bar != null; bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); bar.setTitle(R.string.app_name); TabsAdapter mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bar.newTab().setText(R.string.main_about), AboutTab.class); ActionBar.Tab romTab = bar.newTab().setText(R.string.main_rom); if (cfg.hasStoredRomUpdate()) romTab.setIcon(R.drawable.ic_action_warning); romTabIdx = mTabsAdapter.addTab(romTab, ROMTab.class); /* ActionBar.Tab kernelTab = bar.newTab().setText(R.string.main_kernel); if (cfg.hasStoredKernelUpdate()) kernelTab.setIcon(R.drawable.ic_action_warning); kernelTabIdx = mTabsAdapter.addTab(kernelTab, KernelTab.class); */ if (!handleNotifAction(getIntent())) { if (cfg.hasStoredRomUpdate() && !cfg.isDownloadingRom()) { cfg.getStoredRomUpdate().showUpdateNotif(this); } /* if (cfg.hasStoredKernelUpdate() && !cfg.isDownloadingKernel()) { cfg.getStoredKernelUpdate().showUpdateNotif(this); } */ if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt(KEY_TAB, 0)); } } }
From source file:com.otaupdater.OTAUpdaterActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Context context = getApplicationContext(); cfg = Config.getInstance(context);/*www . jav a 2 s. c o m*/ if (!cfg.hasProKey()) { bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"), billingSrvConn = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { billingSrvConn = null; } @Override public void onServiceConnected(ComponentName name, IBinder binder) { IInAppBillingService service = IInAppBillingService.Stub.asInterface(binder); try { Bundle owned = service.getPurchases(3, getPackageName(), "inapp", null); ArrayList<String> ownedItems = owned.getStringArrayList("INAPP_PURCHASE_ITEM_LIST"); ArrayList<String> ownedItemData = owned .getStringArrayList("INAPP_PURCHASE_DATA_LIST"); if (ownedItems != null && ownedItemData != null) { for (int q = 0; q < ownedItems.size(); q++) { if (ownedItems.get(q).equals(Config.PROKEY_SKU)) { JSONObject itemData = new JSONObject(ownedItemData.get(q)); cfg.setKeyPurchaseToken(itemData.getString("purchaseToken")); break; } } } } catch (RemoteException ignored) { } catch (JSONException e) { e.printStackTrace(); } unbindService(this); billingSrvConn = null; } }, Context.BIND_AUTO_CREATE); } boolean data = Utils.dataAvailable(this); boolean wifi = Utils.wifiConnected(this); if (!data || !wifi) { final boolean nodata = !data && !wifi; if ((nodata && !cfg.getIgnoredDataWarn()) || (!nodata && !cfg.getIgnoredWifiWarn())) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(nodata ? R.string.alert_nodata_title : R.string.alert_nowifi_title); builder.setMessage(nodata ? R.string.alert_nodata_message : R.string.alert_nowifi_message); builder.setCancelable(false); builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); builder.setNeutralButton(R.string.alert_wifi_settings, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Intent i = new Intent(Settings.ACTION_WIFI_SETTINGS); startActivity(i); } }); builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (nodata) { cfg.setIgnoredDataWarn(true); } else { cfg.setIgnoredWifiWarn(true); } dialog.dismiss(); } }); final AlertDialog dlg = builder.create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { onDialogShown(dlg); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { onDialogClosed(dlg); } }); dlg.show(); } } Utils.updateDeviceRegistration(this); CheckinReceiver.setDailyAlarm(this); if (!PropUtils.isRomOtaEnabled() && !PropUtils.isKernelOtaEnabled() && !cfg.getIgnoredUnsupportedWarn()) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.alert_unsupported_title); builder.setMessage(R.string.alert_unsupported_message); builder.setCancelable(false); builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { cfg.setIgnoredUnsupportedWarn(true); dialog.dismiss(); } }); final AlertDialog dlg = builder.create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { onDialogShown(dlg); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { onDialogClosed(dlg); } }); dlg.show(); } setContentView(R.layout.main); Fragment adFragment = getFragmentManager().findFragmentById(R.id.ads); if (adFragment != null) getFragmentManager().beginTransaction().hide(adFragment).commit(); ViewPager mViewPager = (ViewPager) findViewById(R.id.pager); bar = getActionBar(); assert bar != null; bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); bar.setTitle(R.string.app_name); TabsAdapter mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bar.newTab().setText(R.string.main_about), AboutTab.class); ActionBar.Tab romTab = bar.newTab().setText(R.string.main_rom); if (cfg.hasStoredRomUpdate()) romTab.setIcon(R.drawable.ic_action_warning); romTabIdx = mTabsAdapter.addTab(romTab, ROMTab.class); ActionBar.Tab kernelTab = bar.newTab().setText(R.string.main_kernel); if (cfg.hasStoredKernelUpdate()) kernelTab.setIcon(R.drawable.ic_action_warning); kernelTabIdx = mTabsAdapter.addTab(kernelTab, KernelTab.class); if (!handleNotifAction(getIntent())) { if (cfg.hasStoredRomUpdate() && !cfg.isDownloadingRom()) { cfg.getStoredRomUpdate().showUpdateNotif(this); } if (cfg.hasStoredKernelUpdate() && !cfg.isDownloadingKernel()) { cfg.getStoredKernelUpdate().showUpdateNotif(this); } if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt(KEY_TAB, 0)); } } }