@@ -35,6 +35,8 @@ import androidx.appcompat.app.AppCompatActivity
35
35
import androidx.appcompat.app.AppCompatDelegate
36
36
import androidx.core.app.ActivityCompat
37
37
import androidx.core.content.ContextCompat
38
+ import androidx.core.text.bold
39
+ import androidx.core.text.buildSpannedString
38
40
import androidx.recyclerview.widget.RecyclerView
39
41
import com.google.android.material.shape.CornerFamily
40
42
import com.google.android.material.textfield.TextInputLayout
@@ -516,12 +518,18 @@ class MainActivity : AppCompatActivity() {
516
518
title(" Short survey" )
517
519
with (InputEditText {
518
520
required()
521
+ defaultValue(buildSpannedString {
522
+ append(" The " )
523
+ bold{
524
+ append(" Office" )
525
+ }
526
+ })
519
527
startIconDrawable(R .drawable.ic_mail)
520
528
label(" Your favorite TV-Show" )
521
529
hint(" The Mandalorian, ..." )
522
530
inputType(InputType .TYPE_CLASS_TEXT )
523
- changeListener { value -> showToast(" Text change" , value) }
524
- resultListener { value -> showToast(" Text result" , value) }
531
+ changeListener { value -> showToast(" Text change" , value.toString() ) }
532
+ resultListener { value -> showToast(" Text result" , value.toString() ) }
525
533
})
526
534
with (InputCheckBox (" binge_watching" ) { // Read value later by index or custom key from bundle
527
535
label(" Binge Watching" )
@@ -623,15 +631,15 @@ class MainActivity : AppCompatActivity() {
623
631
endIconMode(TextInputLayout .END_ICON_PASSWORD_TOGGLE )
624
632
passwordVisible(false /* Don't display password in clear text. */ )
625
633
validationListener { value ->
626
- password1 = value
634
+ password1 = value.toString()
627
635
val pattern = Pattern .compile(regex)
628
636
val matcher = pattern.matcher(value)
629
637
val valid = matcher.find()
630
638
if (valid) Validation .success()
631
639
else Validation .failed(errorText)
632
640
}
633
- changeListener { value -> showToast(" Text change" , value) }
634
- resultListener { value -> showToast(" Text result" , value) }
641
+ changeListener { value -> showToast(" Text change" , value.toString() ) }
642
+ resultListener { value -> showToast(" Text result" , value.toString() ) }
635
643
})
636
644
with (InputEditText {
637
645
required()
@@ -640,12 +648,12 @@ class MainActivity : AppCompatActivity() {
640
648
endIconMode(TextInputLayout .END_ICON_PASSWORD_TOGGLE )
641
649
passwordVisible(false )
642
650
validationListener { value ->
643
- password2 = value
651
+ password2 = value.toString()
644
652
if (password1 != password2) {
645
653
Validation .failed(" Passwords don't match." )
646
654
} else Validation .success()
647
655
}
648
- resultListener { value -> showToast(" Text result" , value) }
656
+ resultListener { value -> showToast(" Text result" , value.toString() ) }
649
657
})
650
658
onNegative(" cancel" ) { showToast(" InputSheet cancelled" , " No result" ) }
651
659
onPositive(" register" ) {
0 commit comments