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


Java Switch.setVisibility方法代码示例

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


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

示例1: setupSwitches

import android.widget.Switch; //导入方法依赖的package包/类
private void setupSwitches() {
    Switch show_full_zen = view.findViewById(R.id.show_full_zen);
    Switch hu_notif = view.findViewById(R.id.hu_notif);
    Switch vol_warn = view.findViewById(R.id.vol_warn);
    Switch power_notifs = view.findViewById(R.id.power_notifications);
    Switch clock_seconds = view.findViewById(R.id.clock_seconds);
    Switch battery_percent = view.findViewById(R.id.battery_percent);
    CardView power_notif_controls = view.findViewById(R.id.power_notification_controls_card);

    //noinspection deprecation
    battery_percent.setText(Html.fromHtml(getResources().getText(R.string.battery_percentage) + "<br /><small> <font color=\"#777777\">" + getResources().getText(R.string.reboot_required) + "</font></small>"));

    if (Build.VERSION.SDK_INT > 23) {
        clock_seconds.setVisibility(View.VISIBLE); //only show switch if user is on Nougat or later
        power_notif_controls.setVisibility(View.VISIBLE); //this is a Nougat feature; only show it on Nougat devices
    } else {
        clock_seconds.setVisibility(View.GONE);
        power_notif_controls.setVisibility(View.GONE);
    }

    activity.setThings.switches(show_full_zen, SHOW_FULL_ZEN, SECURE, view); //switch listener
    activity.setThings.switches(hu_notif, HUN_ENABLED, GLOBAL, view);
    activity.setThings.switches(vol_warn, SAFE_AUDIO, GLOBAL, view);

    activity.setThings.switches(clock_seconds, CLOCK_SECONDS, SECURE, view);
    activity.setThings.switches(battery_percent, BATTERY_PERCENT, SYSTEM, view);

    activity.setThings.switches(power_notifs, POW_NOTIFS, SECURE, view);
}
 
开发者ID:zacharee,项目名称:SystemUITuner2,代码行数:30,代码来源:Misc.java

示例2: onCreate

import android.widget.Switch; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set a Toolbar to replace the ActionBar.
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    mSwitch = (Switch) toolbar.findViewById(R.id.toolbar_switch);
    rollAllButton = (Button) toolbar.findViewById(R.id.roll_dices_button);
    addTimerButton = (Button) toolbar.findViewById(R.id.add_timer_button);
    delTimerButton = (Button) toolbar.findViewById(R.id.remove_timer_button);
    actionTitle = (TextView) toolbar.findViewById(R.id.custom_toolbar_title);
    mSwitch.setOnCheckedChangeListener(this);
    rollAllButton.setOnClickListener(this);
    addTimerButton.setOnClickListener(this);
    delTimerButton.setOnClickListener(this);
    setSupportActionBar(toolbar);

    // Find our drawer view
    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);

    nvDrawer = (NavigationView) findViewById(R.id.nvView);
    // Setup drawer view
    setupDrawerContent(nvDrawer);


    // Find our drawer view
    drawerToggle = setupDrawerToggle();

    // Tie DrawerLayout events to the ActionBarToggle
    mDrawer.addDrawerListener(drawerToggle);
    getSupportActionBar().setDisplayShowTitleEnabled(false);


    if (getSupportFragmentManager().findFragmentById(R.id.m_content) == null){
        firstFragment = new CounterFragment();
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.m_content, firstFragment).commit();
        //actionTitle.setText(((CounterFragment) firstFragment).getTitle());
        currentTitleString = getString(R.string.menu_counter);
        actionTitle.setText(currentTitleString);

    }else{
        Fragment tempFragment = getSupportFragmentManager().findFragmentById(R.id.m_content);

        if (tempFragment instanceof CounterFragment){
            currentTitleString = getString(R.string.menu_counter);

        }else if (tempFragment instanceof DiceFragment){
            currentTitleString = getString(R.string.menu_dice);
            rollAllButton.setVisibility(View.VISIBLE);

        }else if (tempFragment instanceof ChooserFragment){
            currentTitleString = getString(R.string.menu_chooser);
            mSwitch.setVisibility(View.VISIBLE);

        }else if (tempFragment instanceof TimerFragment){
            currentTitleString = getString(R.string.menu_counter);
            delTimerButton.setVisibility(View.VISIBLE);
            addTimerButton.setVisibility(View.VISIBLE);

        }
        actionTitle.setText(currentTitleString);

    }
}
 
开发者ID:ndleyton,项目名称:OneTwo,代码行数:67,代码来源:MainActivity.java


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