当前位置: 首页>>代码示例>>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;未经允许,请勿转载。