切换与切换 [英] Switch vs toggle

查看:106
本文介绍了切换与切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试决定使用开关还是拨动按钮设置警报,我是我的android应用程序.在android上比较新的知识上,不了解或不太了解框架的所有来龙去脉.选择通过拨动开关触发警报,或者反之亦然有什么缺点? android框架中有可用的幻灯片切换器吗?

I'm trying to decide whether to use a switch or toggle for setting an alarm I'm my android application. On fairly new to android and don't know or quite understand all the ins and outs of the frame work. What would be the disadvantages of choosing to trigger the alarm with a switch over a toggle, or vice versa? Is there a slide toggle available in android framework?

推荐答案

您需要记住的第一件事是,因为您要编译哪个API?

The first thing you need to keep in mind is since which API do you want to compile your app?

API 1 和开关仅从 API 14开始可用.

此外,这只是一个简单的决定,哪个是用户界面/设计的最佳选择 我认为Switch可以清楚地指示当前选择的内容.

Besides that is just a simple decision, which one is the best option for user interface/design In my opinion Switches give a clear indication of what is currently selected.

android框架中是否有可用的幻灯片切换器?

Is there a slide toggle available in android framework?

是的,开关可以用作滑动拨动开关.

Yes a switch can work as a slide toggle.

代码非常简单,您基本上可以对这两个按钮使用相同的思想.

The code is very simple, you can basically use the same thought for these two buttons.

以下是切换按钮"的示例

btnSwitch = (Switch) findViewById(R.id.switch_1);

btnSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
        if (isChecked) {
            Log.i("Switch", "ON");
        } else {
            Log.i("Switch", "OFF");
        }
    }
});

以下是切换按钮的示例

btnToggle = (ToggleButton) findViewById(R.id.toggle_1);

btnToggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {

    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if (isChecked) {
            Log.i("Toggle", "ON");
        } else {
            Log.i("Toggle", "OFF");
        }
    }
});

这篇关于切换与切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆