大约有 366 项符合查询结果(耗时:0.0400秒) [XML]
Android ClickableSpan not calling onClick
...
Kotlin util function:
fun setClickable(textView: TextView, subString: String, handler: () -> Unit, drawUnderline: Boolean = false) {
val text = textView.text
val start = text.indexOf(subString)
val end = start...
How to POST raw whole JSON in the body of a Retrofit request?
...
If using Kotlin use a hashmap of <String, Any>
– peresisUser
Jan 14 '19 at 15:05
|...
I have an error: setOnItemClickListener cannot be used with a spinner, what is wrong?
...
Kotlin:
spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
print("onItemSelected positio...
Get all child views inside LinearLayout at once
...
It is easier with Kotlin using for-in loop:
for (childView in ll.children) {
//childView is a child of ll
}
Here ll is id of LinearLayout defined in layout XML.
...
What is the equivalent of “android:fontFamily=”sans-serif-light" in Java code?
...getResources().getFont(R.font.myfont);
textView.setTypeface(typeface);
// Kotlin
val typeface = resources.getFont(R.font.myfont)
textView.typeface = typeface
Option 2 - API 16 and higher
// Java
Typeface typeface = ResourcesCompat.getFont(context, R.font.myfont);
// Kotlin
val typeface = Resour...
Recommended way to stop a Gradle build
...
are there any nice syntax options here? Consider kotlin's preconditions syntax: require(something != whatever) { "No good!" } as opposed to the more verbose and type-ee if(something != whatever){ throw new GradleException("No good!") }
– Groostav
...
How do you close/hide the Android soft keyboard using Java?
...e it to appear (by holding down the menu).
Note: If you want to do this in Kotlin, use:
context?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
Kotlin Syntax
// Check if no view has focus:
val view = this.currentFocus
view?.let { v ->
val imm = getSystemService(Context.I...
Is there a way to define a min and max value for EditText in Android?
...
Kotlin if any one needs it (Use Utilities)
class InputFilterMinMax: InputFilter {
private var min:Int = 0
private var max:Int = 0
constructor(min:Int, max:Int) {
this.min = min
this.max = max
...
Storing R.drawable IDs in XML array
...
kotlin way could be this:
fun Int.resDrawableArray(context: Context, index: Int, block: (drawableResId: Int) -> Unit) {
val array = context.resources.obtainTypedArray(this)
block(array.getResourceId(index, -1))
arra...
IllegalStateException: Can not perform this action after onSaveInstanceState with ViewPager
... a little for my own project, here is what I do using LifeCycle. I code in Kotlin.
val hostActivity: AppCompatActivity? = null // the activity to host fragments. It's value should be properly initialized.
fun dispatchFragment(frag: Fragment) {
hostActivity?.let {
if(it.lifecyclecurrent...