大约有 850 项符合查询结果(耗时:0.0118秒) [XML]
Android get current Locale, not default
...rationCompat.getLocales(getResources().getConfiguration()).get(0);
or in Kotlin:
val currentLocale = ConfigurationCompat.getLocales(resources.configuration)[0]
share
|
improve this answer
...
Set android shape color programmatically
...uestion was answered a while back, but it can modernized by rewriting as a kotlin extension function.
fun Drawable.overrideColor(@ColorInt colorInt: Int) {
when (this) {
is GradientDrawable -> setColor(colorInt)
is ShapeDrawable -> paint.color = colorInt
is ColorD...
How can you tell when a layout has been drawn?
...
Better with kotlin extension functions
inline fun View.waitForLayout(crossinline yourAction: () -> Unit) {
val vto = viewTreeObserver
vto.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
ov...
Android: Coloring part of a string using TextView.setText()?
...
If you are using Kotlin you can do the following using the android-ktx library
val title = SpannableStringBuilder()
.append("Your big island ")
.bold { append("ADVENTURE") }
titleTextField.text = title
The bold is an exte...
How set maximum date in datepicker dialog in android?
...
Here's a Kotlin extension function:
fun EditText.transformIntoDatePicker(context: Context, format: String, maxDate: Date? = null) {
isFocusableInTouchMode = false
isClickable = true
isFocusable = false
val myCalendar...
Verify object attribute value with mockito
...
And very nice and clean solution in koltin from com.nhaarman.mockito_kotlin
verify(mock).execute(argThat {
this.param = expected
})
share
|
Spring @PropertySource using YAML
...ecent versions of Spring Boot. This is what I do now (please translate the Kotlin to Java if necessary):
@TestPropertySource(locations=["classpath:application.yml"])
@ContextConfiguration(
initializers=[ConfigFileApplicationContextInitializer::class]
)
is added to the top, then
@Conf...
Single TextView with multiple colored text
...
Perfect solution, in all its simplicity. Posted a Kotlin version of this answer. Cheers
– Dan Abnormal
Aug 4 at 10:19
|
...
Hamcrest compare collections
...
Kotlin users: don't forget to add the spread operator (*expectedList.toTypedArray()) when passing an array as varargs!
– James Bowman
Dec 10 '18 at 19:39
...
Email Address Validation in Android on EditText [duplicate]
...(target) && Patterns.EMAIL_ADDRESS.matcher(target).matches());
}
Kotlin:
fun CharSequence?.isValidEmail() = !isNullOrEmpty() && Patterns.EMAIL_ADDRESS.matcher(this).matches()
Edit: It will work On Android 2.2+ onwards !!
Edit: Added missing ;
...