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


Java SwitchCompat.setOnClickListener方法代码示例

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


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

示例1: 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

示例2: convert

import android.support.v7.widget.SwitchCompat; //导入方法依赖的package包/类
@Override
public void convert(ViewHolder holder, final Filter filter) {
    TextView tvFilterName = holder.getView(R.id.tv_filter_name);
    SwitchCompat switchCompat = holder.getView(R.id.swipe_content);
    tvFilterName.setText(filter.name);
    switchCompat.setChecked(filter.isSelected);
    final RecyclerView recyclerView = holder.getView(R.id.recycler_view);
    TableFilterItemAdapter adapter = new TableFilterItemAdapter(context, filter.items, lisenter, filter.isAllcheck);
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(context);
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setAdapter(adapter);
    recyclerView.setVisibility(filter.isSelected ? View.VISIBLE : View.GONE);
    switchCompat.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            filter.isSelected = !filter.isSelected;
            recyclerView.setVisibility(filter.isSelected ? View.VISIBLE : View.GONE);
        }
    });
}
 
开发者ID:jay16,项目名称:shengyiplus-android,代码行数:22,代码来源:TableFilterListAdapter.java

示例3: AlarmHolder

import android.support.v7.widget.SwitchCompat; //导入方法依赖的package包/类
public AlarmHolder(View itemView) {
    super(itemView);
    itemView.setOnClickListener(this);

    mTitleTextView = (TextView) itemView.findViewById(R.id.list_item_alarm_title_text_view);
    mTimeTextView = (TextView) itemView.findViewById(R.id.list_item_alarm_time_text_view);
    mAlarmEnabled = (SwitchCompat) itemView.findViewById(R.id.list_item_alarm_enabled_switch);
    mContainer = (RelativeLayout) itemView.findViewById(R.id.list_item_container);

    mAlarmEnabled.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mAlarmEnabled.isChecked()) {
                long alarmTime = mAlarm.schedule();
                Toast.makeText(getActivity(),
                        DateTimeUtilities.getTimeUntilAlarmDisplayString(getActivity(), alarmTime),
                        Toast.LENGTH_LONG)
                        .show();
            } else {
                mAlarm.cancel();
            }
            mCallbacks.onAlarmChanged();
        }
    });
}
 
开发者ID:Microsoft,项目名称:ProjectOxford-Apps-MimickerAlarm,代码行数:26,代码来源:AlarmListFragment.java

示例4: onCreateView

import android.support.v7.widget.SwitchCompat; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    if (rootView == null) {
        rootView = inflater.inflate(R.layout.fragment_settings, container, false);
        //switchCompatStatus = (SwitchCompat) rootView.findViewById(R.id.switch_status);
        // switchCompatResponse = (SwitchCompat) rootView.findViewById(R.id.switch_response);
        // switchCompatCreated = (SwitchCompat) rootView.findViewById(R.id.switch_created);
        // switchCompatAssignedGroup = (SwitchCompat) rootView.findViewById(R.id.switch_assigned_group);
        // switchCompatAssignedMe = (SwitchCompat) rootView.findViewById(R.id.switch_assigned_me);
        switchCompatCrashReports = (SwitchCompat) rootView.findViewById(R.id.switch_crash_reports);
        switchCompatCrashReports.setChecked(Preference.isCrashReport());
        // switchCompatCrashReports.setOnCheckedChangeListener(this);
        switchCompatCrashReports.setOnClickListener(this);

    }
    ((MainActivity) getActivity()).setActionBarTitle("Settings");
    return rootView;
}
 
开发者ID:ladybirdweb,项目名称:faveo-helpdesk-android-app,代码行数:20,代码来源:Settings.java

示例5: ViewHolder

import android.support.v7.widget.SwitchCompat; //导入方法依赖的package包/类
public ViewHolder(View itemView) {
    super(itemView);
    alarmTitle = (TextView) itemView.findViewById(R.id.lbl_alarm_title);
    alarmTime = (TextView) itemView.findViewById(R.id.lbl_alarm_time);
    alarmStateLabel = (TextView) itemView.findViewById(R.id.lbl_alarm_activation);
    alarmStateSwitch = (SwitchCompat) itemView.findViewById(R.id.swi_alarm_activation);
    alarmIcon = (ImageView) itemView.findViewById(R.id.im_clock);
    alarmIcon.setOnClickListener(this);
    alarmStateSwitch.setOnClickListener(this);
}
 
开发者ID:BracketCove,项目名称:PosTrainer,代码行数:11,代码来源:AlarmListFragment.java

示例6: addItemPrefWithToggle

import android.support.v7.widget.SwitchCompat; //导入方法依赖的package包/类
public ItemBuilder addItemPrefWithToggle(Context context, String title, String subtitle, boolean isChecked, boolean useSwitch, boolean isProFeature, boolean userIsPro, String preferenceCONST, String settingsEnabledAction, String settingsDisabledAction) {
    view = inflater.inflate(R.layout.item_element_title_subtitle_checkbox, parent, false);
    TextView tv = (TextView) view.findViewById(R.id.tv_title);
    tv.setText(title);
    TextView tv2 = (TextView) view.findViewById(R.id.tv_subtitle);
    tv2.setText(subtitle);
    CheckBox     checkboxButton = (CheckBox) view.findViewById(R.id.cb_pref);
    SwitchCompat switchButton   = (SwitchCompat) view.findViewById(R.id.sw_pref);
    checkboxButton.setChecked(isChecked);
    switchButton.setChecked(isChecked);
    if (useSwitch) {
        apply(checkboxButton, GONE);
        apply(switchButton, VISIBLE);
    } else {
        apply(checkboxButton, VISIBLE);
        apply(switchButton, GONE);
    }
    View.OnClickListener listener = view1 -> {
        if (SettingsPreferences.isGenericSettingEnabled(context, preferenceCONST, true)) {
            SettingsPreferences.disableGenericSetting(context, preferenceCONST);
            AnalyticsHelper.getInstance(context).logScreenEvent(SCREEN_SETTINGS, settingsDisabledAction);
            checkboxButton.setChecked(false);
            switchButton.setChecked(false);
        } else {
            SettingsPreferences.enableGenericSetting(context, preferenceCONST);
            AnalyticsHelper.getInstance(context).logScreenEvent(SCREEN_SETTINGS, settingsEnabledAction);
            checkboxButton.setChecked(true);
            switchButton.setChecked(true);
        }
    };
    if (!isProFeature || userIsPro) {
        checkboxButton.setEnabled(true);
        switchButton.setEnabled(true);
        checkboxButton.setOnClickListener(listener);
        switchButton.setOnClickListener(listener);
        view.setOnClickListener(listener);
    } else {
        checkboxButton.setChecked(true);
        switchButton.setChecked(true);
        checkboxButton.setEnabled(false);
        switchButton.setEnabled(false);
    }
    return this;
}
 
开发者ID:albertogiunta,项目名称:justintrain-client-android,代码行数:45,代码来源:ItemBuilder.java


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