当前位置: 首页>>代码示例>>Java>>正文


Java Switch.setOnClickListener方法代码示例

本文整理汇总了Java中android.widget.Switch.setOnClickListener方法的典型用法代码示例。如果您正苦于以下问题:Java Switch.setOnClickListener方法的具体用法?Java Switch.setOnClickListener怎么用?Java Switch.setOnClickListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.Switch的用法示例。


在下文中一共展示了Switch.setOnClickListener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initView

import android.widget.Switch; //导入方法依赖的package包/类
private void initView()
{
    switch_voice= (Switch) findViewById(R.id.switch_voice);
    switch_sms= (Switch) findViewById(R.id.switch_sms);
    ll_check_version= (LinearLayout) findViewById(R.id.ll_check_version);
    tv_version_name= (TextView) findViewById(R.id.tv_version_name);
    ll_scan_qrcode= (LinearLayout) findViewById(R.id.ll_scan_qrcode);
    ll_my_qrcode= (LinearLayout) findViewById(R.id.ll_my_qrcode);
    ll_location= (LinearLayout) findViewById(R.id.ll_location);
    //获取当前版本信息显示在界面上
    showCurrentVersionInfo();
    //为各种开关设置监听事件
    switch_voice.setOnClickListener(this);
    switch_sms.setOnClickListener(this);
    ll_check_version.setOnClickListener(this);
    ll_scan_qrcode.setOnClickListener(this);
    ll_my_qrcode.setOnClickListener(this);
    ll_location.setOnClickListener(this);
    //进入界面后读取之前保存的开关状态
    switch_voice.setChecked(SharedUtils.getBoolean("voice_key",false));
    switch_sms.setChecked(SharedUtils.getBoolean("sms_key",false));
}
 
开发者ID:WindFromFarEast,项目名称:SmartButler,代码行数:23,代码来源:SettingActivity.java

示例2: getView

import android.widget.Switch; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View rowView = inflater.inflate(R.layout.list_item_notification, null, true);

    final NotificationSetting notification = notifications.get(position);
    final Switch notificationSwitch = (Switch) rowView.findViewById(R.id.notificationSwitch);
    final TextView notificationTextView = (TextView) rowView.findViewById(R.id.notificationTextView);

    notificationSwitch.setChecked(notification.isEnabled());
    notificationTextView.setText(notification.getTime());
    if (!notification.isEnabled()) {
        notificationTextView.setTextColor(Color.GRAY);
    }

    notificationSwitch.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            notification.setEnabled(notificationSwitch.isChecked());
            if (notificationSwitch.isChecked()) {
                notificationTextView.setTextColor(Color.BLACK);
            } else {
                notificationTextView.setTextColor(Color.GRAY);
            }
            parentActivity.updateChanges(notifications);
        }
    });

    return rowView;
}
 
开发者ID:BakkerTom,项目名称:happy-news,代码行数:31,代码来源:NotificationAdapter.java

示例3: initView

import android.widget.Switch; //导入方法依赖的package包/类
private void initView() {
    //是否语音
    mSwSpeack = (Switch) findViewById(R.id.sw_speak);
    boolean isSpeak = ShareUtil.getBoolean(this, "isSpeak", false);
    mSwSpeack.setChecked(isSpeak);
    mSwSpeack.setOnClickListener(this);

    //是否短信
    mSwSms = (Switch) findViewById(R.id.sw_sms);
    boolean isSms = ShareUtil.getBoolean(this, "isSms", false);
    mSwSms.setChecked(isSms);
    mSwSms.setOnClickListener(this);

    //检查版本
    mUpdate = (LinearLayout) findViewById(R.id.ll_update);
    mUpdate.setOnClickListener(this);
    mTvVersion = (TextView) findViewById(R.id.tv_version);
    try {
        getVersionNameAndCode();
        mTvVersion.setText(String.format("当前版本:%s", versionName));
    } catch (PackageManager.NameNotFoundException e) {
        mTvVersion.setText("无法获取当前版本,请检查网络");
    }

    //扫一扫
    mQrcodeScan = (LinearLayout) findViewById(R.id.qrcode_scan);
    mQrcodeScan.setOnClickListener(this);
    mScanResult = (TextView) findViewById(R.id.tv_scan_result);

    //生成二维码
    mQrcodeShare = (LinearLayout) findViewById(R.id.qrcode_share);
    mQrcodeShare.setOnClickListener(this);

    //我的位置
    mMyLocation = (LinearLayout) findViewById(R.id.my_location);
    mMyLocation.setOnClickListener(this);

}
 
开发者ID:Hultron,项目名称:LifeHelper,代码行数:39,代码来源:SettingActivity.java

示例4: setBoxes

import android.widget.Switch; //导入方法依赖的package包/类
private void setBoxes() {
    Switch box1= (Switch) findViewById(R.id.prefs_autodel_box);
    Switch box2= (Switch) findViewById(R.id.prefs_askenc_box);
    Switch box3= (Switch) findViewById(R.id.prefs_savepass_box);
    box1.setChecked(SharedData.ASK_DEL_AFTER_ENCRYPTION);
    box2.setChecked(SharedData.ASK_ENCRYPTION_CONFIG);
    box3.setChecked(SharedData.ASK_KEY_PASSS_CONFIG);
    box1.setOnClickListener(this);
    box2.setOnClickListener(this);
    box3.setOnClickListener(this);

}
 
开发者ID:mosamabinomar,项目名称:RootPGPExplorer,代码行数:13,代码来源:PreferencesActivity.java

示例5: onCreate

import android.widget.Switch; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_additive_animations_showcase);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    // load default fragment = tap to move
    getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, new TapToMoveDemoFragment()).commit();
    Switch additiveEnabledSwitch = (Switch) findViewById(R.id.additive_animations_enabled_switch);
    additiveEnabledSwitch.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ADDITIVE_ANIMATIONS_ENABLED = ((Switch)v).isChecked();
        }
    });

    // set the default duration for all animations:
    AdditiveAnimator.setDefaultDuration(1000);
}
 
开发者ID:wirecube,项目名称:android_additive_animations,代码行数:30,代码来源:AdditiveAnimationsShowcaseActivity.java

示例6: initView

import android.widget.Switch; //导入方法依赖的package包/类
private void initView() {

                sw_speak = (Switch) findViewById(R.id.sw_speak);
                sw_speak.setOnClickListener(this);

                boolean isSpeak = getBoolean(this, "isSpeak", false);
                sw_speak.setChecked(isSpeak);

                sw_sms = (Switch) findViewById(R.id.sw_sms);
                sw_sms.setOnClickListener(this);

                boolean isSms = ShareUtil.getBoolean(this, "isSms", false);
                sw_sms.setChecked(isSms);

                tv_version = (TextView) findViewById(R.id.tv_version);

                try {
                        getVersionNameCode();
                        tv_version.setText(getString(R.string.text_test_version) + versionName);
                } catch (PackageManager.NameNotFoundException e) {
                        tv_version.setText(getString(R.string.text_test_version) );
                }

                ll_scan = (LinearLayout) findViewById(R.id.ll_scan);
                ll_scan.setOnClickListener(this);

                tv_scan_result = (TextView) findViewById(R.id.tv_scan_result);

                ll_qr_code = (LinearLayout) findViewById(R.id.ll_qr_code);
                ll_qr_code.setOnClickListener(this);



                ll_about = (LinearLayout) findViewById(R.id.ll_about);
                ll_about.setOnClickListener(this);

                ll_update = (LinearLayout) findViewById(R.id.ll_update);
                ll_update.setOnClickListener(this);
        }
 
开发者ID:lijizhi,项目名称:studydemo,代码行数:40,代码来源:SettingActivity.java


注:本文中的android.widget.Switch.setOnClickListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。