大约有 850 项符合查询结果(耗时:0.0180秒) [XML]
Converting a view to Bitmap without displaying it in Android?
...
There is a great Kotlin extension function in Android KTX: View.drawToBitmap(Bitmap.Config)
share
|
improve this answer
|
...
Set selected index of an Android RadioGroup
...
Using Kotlin you can make it by
(radio_group_id.getChildAt(index) as RadioButton).isChecked = true
or
radio_group_id.check(R.id.radio_button_id)
share
...
Why do most fields (class members) in Android tutorial start with `m`?
...tyle/Java/Code Generation):
Update: we don't use something like this in Kotlin (so it's better to switch to it and don't use prefixes anymore)
share
|
improve this answer
|
...
creating a strikethrough text?
...
If you are using Kotlin:
your_text_view.apply {
paintFlags = paintFlags or Paint.STRIKE_THRU_TEXT_FLAG
text = "Striked thru text"
}
share
|
...
Passing data between a fragment and its container activity
...lic void onDataPass(String data) {
Log.d("LOG","hello " + data);
}
KOTLIN
Step 1. Create Interface
interface OnDataPass {
fun onDataPass(data: String)
}
Step 2. Then, connect the containing class' implementation of the interface to the fragment in the onAttach method (YourFragmen...
How to round an image with Glide library?
...
@RafaelLima It's written in Kotlin.
– Roman Samoilenko
May 30 '18 at 7:19
1
...
Match everything except for specified strings
...mpty items use text.split(/red|green|blue/).findAll {it != ""}) (see demo)
kotlin - text.split(Regex("red|green|blue")) or, to remove blank items, use text.split(Regex("red|green|blue")).filter{ !it.isBlank() }, see demo
scala - text.split("red|green|blue"), or to keep all trailing empty items, use ...
How to define Gradle's home in IDEA?
...usr/local/Cellar/gradle/1.10/), and just append libexec.
The same task in Kotlin in case you use build.gradle.kts:
tasks.register("getHomeDir") {
println("Gradle home dir: ${gradle.gradleHomeDir}")
}
share
|
...
Gridview height gets cut
...
Jacob R solution in Kotlin:
class ExpandableHeightGridView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : GridView(context, attrs, defStyleAttr) {
override fun onMeasure(width...
How to unzip files programmatically in Android?
...
The Kotlin way
//FileExt.kt
data class ZipIO (val entry: ZipEntry, val output: File)
fun File.unzip(unzipLocationRoot: File? = null) {
val rootFolder = unzipLocationRoot ?: File(parentFile.absolutePath + File.separator + ...