當前位置: 首頁>>代碼示例>>Java>>正文


Java SwitchCompat類代碼示例

本文整理匯總了Java中android.support.v7.widget.SwitchCompat的典型用法代碼示例。如果您正苦於以下問題:Java SwitchCompat類的具體用法?Java SwitchCompat怎麽用?Java SwitchCompat使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SwitchCompat類屬於android.support.v7.widget包,在下文中一共展示了SwitchCompat類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initAnimation

import android.support.v7.widget.SwitchCompat; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
private void initAnimation(View view) {
  mSimpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
  mSimpleDraweeView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
  DraweeController controller = Fresco.newDraweeControllerBuilder()
      .setOldController(mSimpleDraweeView.getController())
      .setUri(URI_KEYFRAMES_ANIMATION)
      .setAutoPlayAnimations(true)
      .build();
  mSimpleDraweeView.setController(controller);

  final SwitchCompat switchBackground = (SwitchCompat) view.findViewById(R.id.switch_background);
  switchBackground.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
      mSimpleDraweeView.getHierarchy().setBackgroundImage(isChecked
          ? new CheckerBoardDrawable(getResources())
          : null);
    }
  });
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:ImageFormatKeyframesFragment.java

示例2: onCreate

import android.support.v7.widget.SwitchCompat; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show_settings);

    showID = getIntent().getIntExtra("showID", 0);
    notificationSwitch = (SwitchCompat) findViewById(R.id.notification_switch);
    updateImagesSwitch = (SwitchCompat) findViewById(R.id.update_images_switch);
    posterTV = (TextView) findViewById(R.id.tv_poster);
    bannerTV = (TextView) findViewById(R.id.tv_banner);
    fanArtTV = (TextView) findViewById(R.id.tv_fanart);
    updateImagesLayout = (RelativeLayout) findViewById(R.id.update_images);
    notificationTimeLayout = (LinearLayout) findViewById(R.id.notification_time);
    notificationTimeTV = (TextView) findViewById(R.id.tv_notification_time);

    notificationViewPopulate();
    notificationSwitchListener();
    imagesSwitchListener();
    viewListeners();
}
 
開發者ID:chashmeetsingh,項目名稱:TrackIt-Android,代碼行數:21,代碼來源:ShowSettingsActivity.java

示例3: uiInitBluetooth

import android.support.v7.widget.SwitchCompat; //導入依賴的package包/類
private void uiInitBluetooth() {
    if (bluetooth != null) {

        textBluetoothVisible = (TextView) findViewById(R.id.bluetooth_visible);

        viewBluetoothId = (TextView) findViewById(R.id.device_id_bluetooth);
        viewBluetoothId.setText(bluetooth.getName());
        viewBluetoothId.setVisibility(bluetooth.isEnabled() ? View.VISIBLE : View.GONE);

        int textResource = getManager().isBluetoothDiscoverable() ? R.string.swap_visible_bluetooth : R.string.swap_not_visible_bluetooth;
        textBluetoothVisible.setText(textResource);

        bluetoothSwitch = (SwitchCompat) findViewById(R.id.switch_bluetooth);
        Utils.debugLog(TAG, getManager().isBluetoothDiscoverable() ? "Initially marking switch as checked, because Bluetooth is discoverable." : "Initially marking switch as not-checked, because Bluetooth is not discoverable.");
        bluetoothSwitch.setOnCheckedChangeListener(onBluetoothSwitchToggled);
        setBluetoothSwitchState(getManager().isBluetoothDiscoverable(), true);

        LocalBroadcastManager.getInstance(getContext()).registerReceiver(onBluetoothSwapStateChanged, new IntentFilter(SwapService.BLUETOOTH_STATE_CHANGE));

    } else {
        findViewById(R.id.bluetooth_info).setVisibility(View.GONE);
    }
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:24,代碼來源:StartSwapView.java

示例4: onActivityResult

import android.support.v7.widget.SwitchCompat; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.M)
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    SwitchCompat switchshutdowncountdown = (SwitchCompat) findViewById(R.id.switchshutdowncountdown);

    if (requestCode == REQUEST_CODE) {
        if (android.provider.Settings.canDrawOverlays(Settings_Activity.this)) {
            // continue here - permission was granted
            settingsprefs.edit().putBoolean("sysOverlay", true).apply();
            switchshutdowncountdown.setChecked(true);
        } else {
            settingsprefs.edit().putBoolean("sysOverlay", false).apply();
            switchshutdowncountdown.setChecked(false);
        }
    } else if (requestCode == REQUEST_CODE_ENABLE) {
        settingsprefs.edit().putBoolean("pinprotection", true).apply();
        changepin.setVisibility(View.VISIBLE);
        changepindivider.setVisibility(View.VISIBLE);
    }
}
 
開發者ID:jonathansautter,項目名稱:AutoOff,代碼行數:22,代碼來源:Settings_Activity.java

示例5: initView

import android.support.v7.widget.SwitchCompat; //導入依賴的package包/類
@Override
public void initView() {
        headerLayout = (RelativeLayout) findViewById(R.id.rl_setting_header);
        account = (TextView) findViewById(R.id.tv_setting_account);
        nick = (TextView) findViewById(R.id.tv_tv_setting_nick);
        avatar = (RoundAngleImageView) findViewById(R.id.riv_setting_avatar);
        RelativeLayout notificationLayout = (RelativeLayout) findViewById(R.id.rl_setting_notification);
        ((TextView) notificationLayout.findViewById(R.id.tv_setting_item_title)).setText("通知提醒");
        notification = (SwitchCompat) findViewById(R.id.switch_setting_item_check);
        clear = (LinearLayout) findViewById(R.id.ll_setting_clear);
        ((TextView) clear.findViewById(R.id.tv_group_info_item_layout_title)).setText("清空所有的聊天記錄");
        chatFlow = (TextView) clear.findViewById(R.id.tv_group_info_item_layout_value);
        logout = (Button) findViewById(R.id.btn_setting_logout);
        headerLayout.setOnClickListener(this);
        clear.setOnClickListener(this);
        logout.setOnClickListener(this);
        notification.setOnCheckedChangeListener(this);
}
 
開發者ID:HelloChenJinJun,項目名稱:TestChat,代碼行數:19,代碼來源:SettingsActivity.java

示例6: onCreateOptionsMenu

import android.support.v7.widget.SwitchCompat; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu (Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    MenuItem item = menu.findItem(R.id.action_enable);
    item.setActionView(R.layout.switch_layout);
    SwitchCompat mSwitchEnablePush = item.getActionView().findViewById(R.id.switchForActionBar);
    mSwitchEnablePush.setChecked(PushController.isAllEnable(this));
    mSwitchEnablePush.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            PushController.setAllEnable(b, MainActivity.this);
            Toast.makeText(MainActivity.this,
                    b ? R.string.msg_enable : R.string.msg_disable
                    , Toast.LENGTH_SHORT).show();
        }
    });
    return true;
}
 
開發者ID:Trumeet,項目名稱:MiPushFramework,代碼行數:19,代碼來源:MainActivity.java

示例7: onSharedPreferenceChanged

import android.support.v7.widget.SwitchCompat; //導入依賴的package包/類
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String name) {
    Log.i(TAG, "Preference " + name + "=" + prefs.getAll().get(name));
    if ("log".equals(name)) {
        // Get enabled
        boolean log = prefs.getBoolean(name, false);

        // Display disabled warning
        TextView tvDisabled = (TextView) findViewById(R.id.tvDisabled);
        tvDisabled.setVisibility(log ? View.GONE : View.VISIBLE);

        // Check switch state
        SwitchCompat swEnabled = (SwitchCompat) getSupportActionBar().getCustomView().findViewById(R.id.swEnabled);
        if (swEnabled.isChecked() != log)
            swEnabled.setChecked(log);

        ServiceSinkhole.reload("changed " + name, ActivityLog.this);
    }
}
 
開發者ID:miankai,項目名稱:MKAPP,代碼行數:20,代碼來源:ActivityLog.java

示例8: onCreateView

import android.support.v7.widget.SwitchCompat; //導入依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_apply_on_boot, container, false);

    ((TextView) rootView.findViewById(R.id.title)).setText(getString(R.string.profile_tasker_toast));
    SwitchCompat switchCompat = (SwitchCompat) rootView.findViewById(R.id.switcher);
    switchCompat.setChecked(Prefs.getBoolean("showtaskertoast", true, getActivity()));
    switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            Prefs.saveBoolean("showtaskertoast", b, getActivity());
        }
    });

    return rootView;
}
 
開發者ID:morogoku,項目名稱:MTweaks-KernelAdiutorMOD,代碼行數:19,代碼來源:ProfileFragment.java

示例9: onOptionsChanged

import android.support.v7.widget.SwitchCompat; //導入依賴的package包/類
@Override
public void onOptionsChanged() {
    if (mNativeTranslateInfoBarPtr == 0) return;

    // Handle the "Always Translate" checkbox.
    if (getInfoBarType() == AFTER_TRANSLATE_INFOBAR) {
        SwitchCompat alwaysSwitch = (SwitchCompat) getView().findViewById(
                R.id.translate_infobar_always_toggle);
        mOptions.toggleAlwaysTranslateLanguageState(alwaysSwitch.isChecked());
    }

    if (mOptions.optionsChanged()) {
        nativeApplyTranslateOptions(mNativeTranslateInfoBarPtr, mOptions.sourceLanguageCode(),
                mOptions.targetLanguageCode(), mOptions.alwaysTranslateLanguageState(),
                mOptions.neverTranslateLanguageState(), mOptions.neverTranslateDomainState());
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:18,代碼來源:TranslateInfoBar.java

示例10: convert

import android.support.v7.widget.SwitchCompat; //導入依賴的package包/類
@Override
protected void convert(BaseViewHolder helper, ListBean item) {
    switch (helper.getItemViewType()) {
        case ListItemType.ITEM_NORMAL:
            helper.setText(R.id.tv_arrow_text, item.getText());
            helper.setText(R.id.tv_arrow_value, item.getValue());
            break;

        case ListItemType.ITEM_AVATAR:
            Glide.with(mContext)
                    .load(item.getImageUrl())
                    .diskCacheStrategy(DiskCacheStrategy.ALL).centerCrop().dontAnimate()
                    .into((ImageView) helper.getView(R.id.img_arrow_avatar));

            break;
        case ListItemType.ITEM_SWITCH:
            helper.setText(R.id.tv_arrow_switch_text,item.getText());
            final SwitchCompat switchCompat = helper.getView(R.id.list_item_switch);
            switchCompat.setChecked(true);
            switchCompat.setOnCheckedChangeListener(item.getOnCheckedChangeListener());
            break;

    }
}
 
開發者ID:remerber,項目名稱:FastEc,代碼行數:25,代碼來源:ListAdapter.java

示例11: onCreateOptionsMenu

import android.support.v7.widget.SwitchCompat; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_switch, menu);

    // Get the action view used in your toggleservice item
    final MenuItem toggle = menu.findItem(R.id.menu_switch);
    mSwitch = (SwitchCompat) toggle.getActionView().findViewById(R.id.switchInActionBar);
    mSwitch.setEnabled(mTransportIdEditText.length() > 0 && mEmailEditText.length() > 0 &&
            mPasswordEditText.length() > 0);
    mSwitch.setChecked(mStartButton.getVisibility() != View.VISIBLE);
    mSwitch.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (((SwitchCompat) v).isChecked()) {
                checkInputFields();
            } else {
                confirmStop();
            }
        }
    });
    return super.onCreateOptionsMenu(menu);
}
 
開發者ID:ayushghd,項目名稱:iSPY,代碼行數:24,代碼來源:TrackerActivity.java

示例12: setTint

import android.support.v7.widget.SwitchCompat; //導入依賴的package包/類
public static void setTint(@NonNull SwitchCompat switchView, @ColorInt int color, boolean useDarker) {
    if (switchView.getTrackDrawable() != null) {
        switchView.setTrackDrawable(modifySwitchDrawable(switchView.getContext(),
                switchView.getTrackDrawable(), color, false, true, useDarker));
    }
    if (switchView.getThumbDrawable() != null) {
        switchView.setThumbDrawable(modifySwitchDrawable(switchView.getContext(),
                switchView.getThumbDrawable(), color, true, true, useDarker));
    }
}
 
開發者ID:GlennioTech,項目名稱:MetadataEditor,代碼行數:11,代碼來源:TintHelper.java

示例13: initView

import android.support.v7.widget.SwitchCompat; //導入依賴的package包/類
@Override
protected void initView(Bundle bundle) {
    super.initView(bundle);
    GlideManager.loadCircleImg("https://avatars3.githubusercontent.com/u/19605922?v=4&s=460", ivHead);
    titleBarDrawer.setImmersible(mContext, isImmersible, isLight);
    vHeader = View.inflate(mContext, R.layout.layout_title_header, null);
    sBtnImmersible = (SwitchCompat) vHeader.findViewById(R.id.sBtn_immersible);
    sBtnLight = (SwitchCompat) vHeader.findViewById(R.id.sBtn_light);
    sBtnLine = (SwitchCompat) vHeader.findViewById(R.id.sBtn_line);
    lLayoutAlpha = (LinearLayout) vHeader.findViewById(R.id.lLayout_alpha);
    sBarAlpha = (SeekBar) vHeader.findViewById(R.id.sBar_alpha);
    tvStatusAlpha = (TextView) vHeader.findViewById(R.id.tv_statusAlpha);
    initView();
    setDrawerList();
    initData();
}
 
開發者ID:AriesHoo,項目名稱:TitleBarView,代碼行數:17,代碼來源:MainActivity.java

示例14: initView

import android.support.v7.widget.SwitchCompat; //導入依賴的package包/類
@Override
    protected void initView(Bundle bundle) {
        super.initView(bundle);

//        drawerRoot.setScrimColor(0x00ffffff);//背景高亮
//        drawerRoot.setDrawerElevation(40);//海拔高度
        mContentView.setBackgroundDrawable(null);
        GlideManager.loadCircleImg("https://avatars3.githubusercontent.com/u/19605922?v=4&s=460", ivHead);
        titleBarDrawer.setImmersible(mContext, isImmersible, isLight);
        vHeader = View.inflate(mContext, R.layout.layout_title_header, null);
        sBtnImmersible = (SwitchCompat) vHeader.findViewById(R.id.sBtn_immersible);
        sBtnLight = (SwitchCompat) vHeader.findViewById(R.id.sBtn_light);
        sBtnLine = (SwitchCompat) vHeader.findViewById(R.id.sBtn_line);
        lLayoutAlpha = (LinearLayout) vHeader.findViewById(R.id.lLayout_alpha);
        sBarAlpha = (SeekBar) vHeader.findViewById(R.id.sBar_alpha);
        tvStatusAlpha = (TextView) vHeader.findViewById(R.id.tv_statusAlpha);
        initView();
        setDrawerList();
        initData();
    }
 
開發者ID:AriesHoo,項目名稱:UIWidget,代碼行數:21,代碼來源:TitleActivity.java

示例15: initVariables

import android.support.v7.widget.SwitchCompat; //導入依賴的package包/類
private void initVariables() {
    thisActivity = this;
    localIPText = findViewById(R.id.my_local_ip);
    externalIPText = findViewById(R.id.my_external_ip);
    statusText = findViewById(R.id.status);
    statusText.setMovementMethod(new ScrollingMovementMethod());

    sendButton = (Button) findViewById(R.id.send_button);
    messageEditText = (EditText) findViewById(R.id.message_edit_text);
    extraInformationPanel = (LinearLayout) findViewById(R.id.extra_information_panel);
    developerModeText = (TextView) findViewById(R.id.developer_mode_text);
    switchDeveloperMode = (SwitchCompat) findViewById(R.id.switch_developer_mode);
    switchDeveloperMode.setOnCheckedChangeListener(this);

    editTextDestinationIP = findViewById(R.id.destination_IP);
    editTextDestinationPort = findViewById(R.id.destination_port);
}
 
開發者ID:wkmeijer,項目名稱:CS4160-trustchain-android,代碼行數:18,代碼來源:TrustChainActivity.java


注:本文中的android.support.v7.widget.SwitchCompat類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。