android.widget.Switch Java Examples
The following examples show how to use
android.widget.Switch.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DebugDrawerMockBle.java From android-ponewheel with MIT License | 6 votes |
@NonNull @Override public View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) { View view = inflater.inflate(R.layout.debug_drawer_mock_ble, parent, false); Switch mockBle = view.findViewById(R.id.debug_drawer_ble_mock); mockBle.setOnCheckedChangeListener((buttonView, isChecked) -> { if (isChecked) { mainActivity.provideBluetoothUtil(new BluetoothUtilMockImpl()); } else { mainActivity.provideBluetoothUtil(new BluetoothUtilImpl()); } }); return view; }
Example #2
Source File: MainActivity.java From MockSMS with Apache License 2.0 | 6 votes |
private Switch.OnCheckedChangeListener listener(final int roll) { return new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (roll == ROLL.READ.ordinal()) { Extra.getInstance(getBaseContext()).setRead(isChecked); } else if (roll == ROLL.SEEN.ordinal()) { Extra.getInstance(getBaseContext()).setSeen(isChecked); } else if (roll == ROLL.DELIVERED.ordinal()) { Extra.getInstance(getBaseContext()).setDelivered(isChecked); } else if (roll == ROLL.SLOT.ordinal()) { Extra.getInstance(getBaseContext()).setSLOT_ENABLED(isChecked); } else if (roll == ROLL.IMSI.ordinal()) { Extra.getInstance(getBaseContext()).setIMSI_ENABLED(isChecked); } else if (roll == ROLL.REPLY_PATH.ordinal()) { Extra.getInstance(getBaseContext()).setREPLY_PATH_PRESENT(isChecked); } else if (roll == ROLL.SERVICE_CENTER.ordinal()) { Extra.getInstance(getBaseContext()).setServiceCenterBool(isChecked); } else if (roll == ROLL.TIME_DIFFERENCE.ordinal()) { Extra.getInstance(getBaseContext()).setTimeDifferenceBool(isChecked); } else if (roll == ROLL.STATUS.ordinal()) { Extra.getInstance(getBaseContext()).setSmsStatusBool(isChecked); } } }; }
Example #3
Source File: AppRestrictionEnforcerFragment.java From android-AppRestrictionEnforcer with Apache License 2.0 | 6 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { // Retain references for the UI elements mSwitchSayHello = (Switch) view.findViewById(R.id.say_hello); mEditMessage = (EditText) view.findViewById(R.id.message); mEditNumber = (EditText) view.findViewById(R.id.number); mSpinnerRank = (Spinner) view.findViewById(R.id.rank); mLayoutApprovals = (LinearLayout) view.findViewById(R.id.approvals); mLayoutItems = (LinearLayout) view.findViewById(R.id.items); view.findViewById(R.id.item_add).setOnClickListener(this); View bundleArrayLayout = view.findViewById(R.id.bundle_array_layout); if (BUNDLE_SUPPORTED) { bundleArrayLayout.setVisibility(View.VISIBLE); } else { bundleArrayLayout.setVisibility(View.GONE); } }
Example #4
Source File: SwitchPreference.java From DeviceConnect-Android with MIT License | 6 votes |
/** * Clear listener in Switch for specify ViewGroup. * * @param viewGroup The ViewGroup that will need to clear the listener. */ private void clearListenerInViewGroup(final ViewGroup viewGroup) { if (null == viewGroup) { return; } int count = viewGroup.getChildCount(); for (int n = 0; n < count; ++n) { View childView = viewGroup.getChildAt(n); if (childView instanceof Switch) { final Switch switchView = (Switch) childView; switchView.setOnCheckedChangeListener(null); return; } else if (childView instanceof ViewGroup) { ViewGroup childGroup = (ViewGroup) childView; clearListenerInViewGroup(childGroup); } } }
Example #5
Source File: SettingsMenu.java From ViewInspector with Apache License 2.0 | 6 votes |
public SettingsMenu(final Context context) { super(context); ViewInspector.runtimeComponentMap.get(context).inject(this); inflate(context, R.layout.view_inspector_settings_menu, this); Switch logViewEventsSwitch = (Switch) findViewById(R.id.log_view_events_switch); logViewEventsSwitch.setChecked(logViewEvents.get()); logViewEventsSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { logViewEvents.set(isChecked); } }); View viewFilter = findViewById(R.id.view_filter); viewFilter.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new SetViewFilterDialog( new ContextThemeWrapper(context, BaseDialog.getDialogTheme(context))).show(); } }); }
Example #6
Source File: MainActivity.java From shadowsocks-android-java with Apache License 2.0 | 6 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main_activity_actions, menu); MenuItem menuItem = menu.findItem(R.id.menu_item_switch); if (menuItem == null) { return false; } switchProxy = (Switch) menuItem.getActionView(); if (switchProxy == null) { return false; } switchProxy.setChecked(LocalVpnService.IsRunning); switchProxy.setOnCheckedChangeListener(this); return true; }
Example #7
Source File: SwitchPreference.java From DeviceConnect-Android with MIT License | 6 votes |
/** * Clear listener in Switch for specify ViewGroup. * * @param viewGroup The ViewGroup that will need to clear the listener. */ private void clearListenerInViewGroup(final ViewGroup viewGroup) { if (null == viewGroup) { return; } int count = viewGroup.getChildCount(); for(int n = 0; n < count; ++n) { View childView = viewGroup.getChildAt(n); if(childView instanceof Switch) { final Switch switchView = (Switch) childView; switchView.setOnCheckedChangeListener(null); return; } else if (childView instanceof ViewGroup){ ViewGroup childGroup = (ViewGroup)childView; clearListenerInViewGroup(childGroup); } } }
Example #8
Source File: SettingFragment.java From easyweather with MIT License | 6 votes |
public void switchStatus(Switch aSwitch, final String fileName, final int flag) { aSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { SharedPreferences settings = getActivity().getSharedPreferences(fileName, Context.MODE_PRIVATE); SharedPreferences.Editor edit = settings.edit(); edit.putBoolean("ischecked", isChecked); edit.apply(); if (isChecked) { if (flag == 2) { getActivity().startService(new Intent(getActivity(), NotificationService.class)); } }else{ if (flag == 2) { getActivity().stopService(new Intent(getActivity(), NotificationService.class)); } } } }); }
Example #9
Source File: HeaderViewHolder.java From geopackage-mapcache-android with MIT License | 6 votes |
/** * Constructor * @param itemView View to be created * @param backListener - A click listener which should set the RecyclerView to contain the * list of GeoPackages again */ public HeaderViewHolder(View itemView, View.OnClickListener backListener, DetailActionListener actionListener, EnableAllLayersListener enableAllListener, GeoPackageDatabase db) { super(itemView); detailHeaderMain = (View)itemView.findViewById(R.id.detailHeaderMain); textName = (TextView) itemView.findViewById(R.id.headerTitle); textSize = (TextView) itemView.findViewById(R.id.headerSize); textFeatures = (TextView) itemView.findViewById(R.id.header_text_features); textTiles = (TextView) itemView.findViewById(R.id.header_text_tiles); backArrow = (ImageButton) itemView.findViewById(R.id.detailPageBackButton); enableAllSwitch = (Switch) itemView.findViewById(R.id.header_all_switch); backArrow.setOnClickListener(backListener); this.actionListener = actionListener; mEnableAllListener = enableAllListener; mDb = db; setActionButtonListeners(); ViewAnimation.setSlideInFromRightAnimation(detailHeaderMain, 200); }
Example #10
Source File: SampleActivity.java From scalpel with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sample_activity); ButterKnife.inject(this); pagerView.setAdapter(new SamplePagerAdapter(this)); Switch enabledSwitch = new Switch(this); enabledSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (first) { first = false; Toast.makeText(SampleActivity.this, R.string.first_run, LENGTH_LONG).show(); } scalpelView.setLayerInteractionEnabled(isChecked); invalidateOptionsMenu(); } }); ActionBar actionBar = getActionBar(); actionBar.setCustomView(enabledSwitch); actionBar.setDisplayOptions(DISPLAY_SHOW_TITLE | DISPLAY_SHOW_CUSTOM); }
Example #11
Source File: ToggleElement.java From debugdrawer with Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup root) { final Context context = root.getContext(); checked = new BooleanPreference( context.getSharedPreferences(getKey(),Context.MODE_PRIVATE), getTitle(), String.valueOf(defaultValue)); if(!checked.isSet()) checked.set(defaultValue); aSwitch = new Switch(new ContextThemeWrapper(context, R.style.Widget_U2020_DebugDrawer_RowWidget)); aSwitch.setText(title); aSwitch.setChecked(checked.get()); aSwitch.setEnabled(isEnabled()); aSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { checked.set(isChecked); onSwitch(isChecked); } }); aSwitch.setGravity(Gravity.START | Gravity.END | Gravity.CENTER_VERTICAL); // "start|end|center_vertical" return aSwitch; }
Example #12
Source File: SetOtherFragment.java From XposedNavigationBar with GNU General Public License v3.0 | 6 votes |
@Override void initView(View view) { btnHomePoint = (LinearLayout) view.findViewById(R.id.btn_home_point); tvHomePosition = (TextView) view.findViewById(R.id.tv_home_position); btnClearMemLevel = (LinearLayout) view.findViewById(R.id.btn_clear_mem_level); tvClearMemLevel = (TextView) view.findViewById(R.id.tv_clear_mem_level); btnIconSize = (LinearLayout) view.findViewById(R.id.btn_icon_size); tvIconSize = (TextView) view.findViewById(R.id.tv_icon_size); // swHook90 = (Switch) findViewById(R.id.sw_hook_90); swRootDown = (Switch) view.findViewById(R.id.sw_root_down); settingAboutMarshmallow = (LinearLayout) view.findViewById(R.id.setting_about_marshmallow); swChameleonNavbar = (Switch) view.findViewById(R.id.sw_chameleon_navbar); btnNavbarHeight = (LinearLayout) view.findViewById(R.id.btn_navbar_height); tvNavbarHeight = (TextView) view.findViewById(R.id.tv_navbar_height); swVibrate = (Switch) view.findViewById(R.id.sw_navbar_vibrate); swHideAppIcon = (Switch) view.findViewById(R.id.sw_hide_app_icon); swNavbarHeight = (Switch) view.findViewById(R.id.sw_navbar_height); swGoHome = (Switch) view.findViewById(R.id.sw_go_home); }
Example #13
Source File: MapFragment.java From MapForTour with MIT License | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_map, container, false); // Inflate the layout for this fragment switchLocation = (Switch) view.findViewById(R.id.switchLocation); switchLBSTrace = (Switch) view.findViewById(R.id.switchLBSTrace); switchLocation.setOnCheckedChangeListener(this); switchLBSTrace.setOnCheckedChangeListener(this); mMapView = (TextureMapView) view.findViewById(R.id.bmapView); baiduMap = mMapView.getMap(); baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, false, null)); application.setMaxZoomLevel(baiduMap.getMaxZoomLevel()); // 开启定位图层 baiduMap.setMyLocationEnabled(true); baiduMap.setOnMarkerClickListener(this); //再次进入地图fragment时界面刷新 if (application.latLng != null) { MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(application.getLatLng(), application.getMaxZoomLevel() - 2); baiduMap.animateMapStatus(u);//动画移动摄像头 if (radarNearbyInfoList != null) { refreshMapUI(); } } return view; }
Example #14
Source File: BasicManagedProfileFragment.java From enterprise-samples with Apache License 2.0 | 6 votes |
@Override public void onViewCreated(View view, Bundle savedInstanceState) { // Bind event listeners and initial states view.findViewById(R.id.set_chrome_restrictions).setOnClickListener(this); view.findViewById(R.id.clear_chrome_restrictions).setOnClickListener(this); view.findViewById(R.id.enable_forwarding).setOnClickListener(this); view.findViewById(R.id.disable_forwarding).setOnClickListener(this); view.findViewById(R.id.send_intent).setOnClickListener(this); mButtonRemoveProfile = (Button) view.findViewById(R.id.remove_profile); mButtonRemoveProfile.setOnClickListener(this); Switch toggleCalculator = (Switch) view.findViewById(R.id.toggle_calculator); toggleCalculator.setChecked(mCalculatorEnabled); toggleCalculator.setOnCheckedChangeListener(this); Switch toggleChrome = (Switch) view.findViewById(R.id.toggle_chrome); toggleChrome.setChecked(mChromeEnabled); toggleChrome.setOnCheckedChangeListener(this); }
Example #15
Source File: MainActivity.java From aosp_screen_stabilization with Apache License 2.0 | 6 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); Switch switchSvc = (Switch) menu.findItem(R.id.action_svc_switch).getActionView().findViewById(R.id.switch_svc); switchSvc.setChecked(settings.isServiceEnabled()); switchSvc.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { setSvcEnabled(isChecked); } }); return true; }
Example #16
Source File: ModifyModulePreference.java From GNSS_Compare with Apache License 2.0 | 6 votes |
/** * Defines the active Switch * @param v used view * @param pos item pos */ private void defineActiveSwitch(View v, final int pos){ Switch switchReference = v.findViewById(R.id.on_switch); switchReference.setChecked(getItem(pos).getCalculationModuleReference().getActive()); switchReference.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { getItem(pos).getCalculationModuleReference().setActive(isChecked); String notificationText; if (isChecked) notificationText = "Calculations activated"; else notificationText = "Calculations deactivated"; Snackbar snackbar = Snackbar .make(mainView, notificationText, Snackbar.LENGTH_SHORT); snackbar.show(); } }); }
Example #17
Source File: CheckBox.java From PowerFileExplorer with GNU General Public License v3.0 | 6 votes |
/** * Clear listener in Switch for specify ViewGroup. * * @param viewGroup The ViewGroup that will need to clear the listener. */ private void clearListenerInViewGroup(ViewGroup viewGroup) { if (null == viewGroup) { return; } int count = viewGroup.getChildCount(); for(int n = 0; n < count; ++n) { View childView = viewGroup.getChildAt(n); if(childView instanceof Switch) { final Switch switchView = (Switch) childView; switchView.setOnCheckedChangeListener(null); return; } else if (childView instanceof ViewGroup){ ViewGroup childGroup = (ViewGroup)childView; clearListenerInViewGroup(childGroup); } } }
Example #18
Source File: DeviceActivity.java From gree-remote with GNU General Public License v3.0 | 5 votes |
private boolean isSwitchChecked(int id) { View view = findViewById(id); if (view instanceof Switch) { return ((Switch) view).isChecked(); } return false; }
Example #19
Source File: SettingsActivity.java From InjuredAndroid with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); Switch darkModeSwitch = findViewById(R.id.switch1); darkModeSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> { if (isChecked) { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); } else { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); } }); }
Example #20
Source File: LinkingBeaconListFragment.java From DeviceConnect-Android with MIT License | 5 votes |
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { mAdapter = new ListAdapter(getActivity(), -1); final View root = inflater.inflate(R.layout.fragment_linking_beacon_list, container, false); ListView listView = root.findViewById(R.id.fragment_beacon_list_view); listView.setOnItemClickListener((parent, view, position, id) -> { DeviceItem item = (DeviceItem) view.getTag(); if (item != null) { transitionBeaconControl(item); } }); listView.setOnItemLongClickListener((parent, view, position, id) -> { confirmDeleteBeacon(mAdapter.getItem(position).mDevice); return true; }); listView.setAdapter(mAdapter); Switch switchBtn = (Switch) root.findViewById(R.id.fragment_beacon_scan_switch); if (switchBtn != null) { switchBtn.setOnCheckedChangeListener((buttonView, isChecked) -> { if (isChecked) { getLinkingBeaconManager().startForceBeaconScan(); } else { getLinkingBeaconManager().stopForceBeaconScan(); } }); switchBtn.setChecked(getLinkingBeaconManager().isStartedForceBeaconScan()); } return root; }
Example #21
Source File: Demo.java From SystemUITuner2 with MIT License | 5 votes |
private void setBatteryPlugged(Switch toggle) { toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { activity.setThings.editor.putBoolean("isCharging", true); batteryPlugged = "true"; } else { activity.setThings.editor.putBoolean("isCharging", false); batteryPlugged = "false"; } activity.setThings.editor.apply(); } }); }
Example #22
Source File: SettingsActivity.java From android-AutofillFramework with Apache License 2.0 | 5 votes |
private void setupSettingsSwitch(int containerId, int labelId, int switchId, boolean checked, CompoundButton.OnCheckedChangeListener checkedChangeListener) { ViewGroup container = findViewById(containerId); String switchLabel = ((TextView) container.findViewById(labelId)).getText().toString(); final Switch switchView = container.findViewById(switchId); switchView.setContentDescription(switchLabel); switchView.setChecked(checked); container.setOnClickListener((view) -> switchView.performClick()); switchView.setOnCheckedChangeListener(checkedChangeListener); }
Example #23
Source File: SettingActivity.java From Google-Hosts with Apache License 2.0 | 5 votes |
private void intView() { //设置对toolBar的支持 Toolbar toolBar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolBar); //设置默认按钮的支持 ActionBar supportActionBar = getSupportActionBar(); if (supportActionBar != null) { supportActionBar.setDisplayHomeAsUpEnabled(true); } mTvState = (TextView) findViewById(R.id.tv_state); mSwitchState = (Switch) findViewById(R.id.st_state); mSwitchState.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { //根据按钮的状态保存是否更新的设置 if (b) { SPUtils.putBoolean(getApplicationContext(), ConstantValues.AUTO_UPDATE, true); } else { SPUtils.putBoolean(getApplicationContext(), ConstantValues.AUTO_UPDATE, false); } //更新数据 initData(); } }); }
Example #24
Source File: DefaultBrowserPreference.java From focus-android with Mozilla Public License 2.0 | 5 votes |
@Override public void onBindViewHolder(PreferenceViewHolder holder) { super.onBindViewHolder(holder); switchView = (Switch) holder.findViewById(R.id.switch_widget); update(); }
Example #25
Source File: LogToFile.java From your-local-weather with GNU General Public License v3.0 | 5 votes |
public static void appendLog(Context context, String tag, String text1, WeatherForecastDbHelper.WeatherForecastRecord value1, String text2, Switch value2) { checkPreferences(context); if (!logToFileEnabled || (logFilePathname == null)) { return; } appendLog(context, tag, text1, (value1 != null)? value1.toString() : "null", text2, (value2 != null)? value2.toString() : "null"); }
Example #26
Source File: MainActivity.java From android-material-motion with Apache License 2.0 | 5 votes |
private void setupWarning() { preferences = PreferenceManager.getDefaultSharedPreferences(this); preferences.registerOnSharedPreferenceChangeListener(this); onSharedPreferenceChanged(preferences, WARNING_KEY); final MenuItem item = navigation.getMenu().findItem(R.id.enable_message); Switch view = (Switch) MenuItemCompat.getActionView(item); view.setChecked(preferences.getBoolean(WARNING_KEY, false)); view.setOnCheckedChangeListener((button, isChecked) -> { if (enabledWarning != isChecked) { preferences.edit() .putBoolean(WARNING_KEY, isChecked) .apply(); } }); }
Example #27
Source File: InstallFromListActivity.java From commcare-android with Apache License 2.0 | 5 votes |
private void setUpToggle() { FrameLayout toggleContainer = findViewById(R.id.toggle_button_container); CompoundButton userTypeToggler; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { Switch switchButton = new Switch(this); switchButton.setTextOff(Localization.get("toggle.web.user.mode")); switchButton.setTextOn(Localization.get("toggle.mobile.user.mode")); userTypeToggler = switchButton; } else { ToggleButton toggleButton = new ToggleButton(this); toggleButton.setTextOff(Localization.get("toggle.web.user.mode")); toggleButton.setTextOn(Localization.get("toggle.mobile.user.mode")); userTypeToggler = toggleButton; } // Important for this call to come first; we don't want the listener to be invoked on the // first auto-setting, just on user-triggered ones userTypeToggler.setChecked(inMobileUserAuthMode); userTypeToggler.setOnCheckedChangeListener((buttonView, isChecked) -> { inMobileUserAuthMode = isChecked; errorMessage = null; errorMessageBox.setVisibility(View.INVISIBLE); ((EditText)findViewById(R.id.edit_password)).setText(""); setProperAuthView(); }); toggleContainer.addView(userTypeToggler); }
Example #28
Source File: AdvertiserFragment.java From connectivity-samples with Apache License 2.0 | 5 votes |
/** * Called when switch is toggled - starts or stops advertising. */ @Override public void onClick(View v) { // Is the toggle on? boolean on = ((Switch) v).isChecked(); if (on) { startAdvertising(); } else { stopAdvertising(); } }
Example #29
Source File: BooleanOptionItemTest.java From msdkui-android with Apache License 2.0 | 5 votes |
@Test public void testInitUi() { final TextView labelView = (TextView) mBooleanOptionItem.findViewById(R.id.boolean_item_label); final Switch valueView = (Switch) mBooleanOptionItem.findViewById(R.id.boolean_item_value); assertNotNull(labelView); assertThat(labelView.getVisibility(), equalTo(View.VISIBLE)); assertNotNull(valueView); assertThat(valueView.getVisibility(), equalTo(View.VISIBLE)); }
Example #30
Source File: TintHelper.java From MyBookshelf with GNU General Public License v3.0 | 5 votes |
public static void setTint(@NonNull Switch switchView, @ColorInt int color, boolean useDarker) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) return; if (switchView.getTrackDrawable() != null) { switchView.setTrackDrawable(modifySwitchDrawable(switchView.getContext(), switchView.getTrackDrawable(), color, false, false, useDarker)); } if (switchView.getThumbDrawable() != null) { switchView.setThumbDrawable(modifySwitchDrawable(switchView.getContext(), switchView.getThumbDrawable(), color, true, false, useDarker)); } }