Source code for enamlnative.android.android_toggle_button

"""
Copyright (c) 2017-2022, CodeLV.

Distributed under the terms of the MIT License.

The full license is in the file LICENSE, distributed with this software.

Created on June 7, 2017


"""
from atom.api import Typed
from enamlnative.widgets.toggle_button import ProxyToggleButton
from .android_compound_button import AndroidCompoundButton, CompoundButton
from .bridge import JavaMethod


class ToggleButton(CompoundButton):
    __nativeclass__ = "android.widget.ToggleButton"
    setTextOff = JavaMethod("java.lang.CharSequence")
    setTextOn = JavaMethod("java.lang.CharSequence")


[docs]class AndroidToggleButton(AndroidCompoundButton, ProxyToggleButton): """An Android implementation of an Enaml ProxyToggleButton.""" #: A reference to the widget created by the proxy. widget = Typed(ToggleButton) # ------------------------------------------------------------------------- # Initialization API # -------------------------------------------------------------------------
[docs] def create_widget(self): """Create the underlying widget.""" d = self.declaration self.widget = ToggleButton( self.get_context(), None, d.style or "@attr/buttonStyleToggle" )
# ------------------------------------------------------------------------- # ProxyToggleButton API # ------------------------------------------------------------------------- def set_text_off(self, text): self.widget.setTextOff(text) def set_text_on(self, text): self.widget.setTextOn(text)