本文整理汇总了Scala中android.widget.Switch类的典型用法代码示例。如果您正苦于以下问题:Scala Switch类的具体用法?Scala Switch怎么用?Scala Switch使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Switch类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: ConfigView
//设置package包名称以及导入依赖的类
package fr.magistry.taigime2
import Message.Config
import android.content.Context
import android.util.Log
import android.view.{LayoutInflater, View}
import android.view.View.OnClickListener
import android.widget.{Button, CheckBox, Switch}
class ConfigView(context: Context, ime: TaigIME) {
val keyFuzzyLookup = "fuzzyLookup"
val keyPojOrTL = "POJorTL"
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE).asInstanceOf[LayoutInflater]
val view = inflater.inflate(R.layout.config, null)
val cbFuzzy = view.findViewById(R.id.cbFuzzy).asInstanceOf[CheckBox]
val swRomanization = view.findViewById(R.id.swPOJTL).asInstanceOf[Switch]
setValues()
view
.findViewById(R.id.acceptConfig)
.asInstanceOf[Button]
.setOnClickListener(new OnClickListener {
override def onClick(v: View): Unit = {
context.getSharedPreferences("TaigIME2",0)
.edit()
.putBoolean(keyFuzzyLookup, cbFuzzy.isChecked)
.putBoolean(keyPojOrTL,swRomanization.isChecked)
.apply()
Log.v("IME","validate config")
ime.message(Message.ConfigChanged(Config(cbFuzzy.isChecked, swRomanization.isChecked)))
ime.message(Message.ChangeKeyboard)
}
})
def setValues(): Unit = {
val prefs = context.getSharedPreferences("TaigIME2", 0)
val fuzzy = prefs.getBoolean(keyFuzzyLookup,true)
val pojtr = prefs.getBoolean(keyPojOrTL, false)
cbFuzzy.setChecked(fuzzy)
swRomanization.setChecked(pojtr)
}
}