大约有 366 项符合查询结果(耗时:0.0259秒) [XML]

https://stackoverflow.com/ques... 

How to set OnClickListener on a RadioButton in Android?

... question isn't specific to Java, I would like to add how you can do it in Kotlin: radio_group_id.setOnCheckedChangeListener({ radioGroup, optionId -> { when (optionId) { R.id.radio_button_1 -> { // do something when radio button 1 is selected }...
https://stackoverflow.com/ques... 

Android Use Done button on Keyboard to click button

... Kotlin Solution The base way to handle the done action in Kotlin is: edittext.setOnEditorActionListener { _, actionId, _ -> if (actionId == EditorInfo.IME_ACTION_DONE) { // Call your code here true ...
https://stackoverflow.com/ques... 

How set the android:gravity to TextView from Java side in Android

... labelTV.setGravity(Gravity.CENTER | Gravity.BOTTOM); Kotlin version (thanks to Thommy) labelTV.gravity = Gravity.CENTER_HORIZONTAL or Gravity.BOTTOM Also, are you talking about gravity or about layout_gravity? The latter won't work in a RelativeLayout. ...
https://stackoverflow.com/ques... 

Android: ScrollView force to bottom

...ew.FOCUS_DOWN) also should work. Put this in a scroll.Post(Runnable run) Kotlin Code scrollView.post { scrollView.fullScroll(View.FOCUS_DOWN) } share | improve this answer | ...
https://stackoverflow.com/ques... 

In Android EditText, how to force writing uppercase?

... Or in Kotlin just editText.filters = editText.filters + InputFilter.AllCaps() – Ilia Kurtov Sep 27 '18 at 16:35 ...
https://stackoverflow.com/ques... 

Android: How to put an Enum in a Bundle?

... I use kotlin. companion object { enum class Mode { MODE_REFERENCE, MODE_DOWNLOAD } } then put into Intent: intent.putExtra(KEY_MODE, Mode.MODE_DOWNLOAD.name) when you net to get value:...
https://stackoverflow.com/ques... 

How to determine MIME type of file in android?

...lowercase! Update (19.03.2018) Bonus: Above methods as a less verbose Kotlin extension function: fun File.getMimeType(fallback: String = "image/*"): String { return MimeTypeMap.getFileExtensionFromUrl(toString()) ?.run { MimeTypeMap.getSingleton().getMimeTypeFromExtension(toLow...
https://stackoverflow.com/ques... 

How to get hosting Activity from a view?

... I like this solution written in Kotlin tailrec fun Context?.getActivity(): Activity? = when (this) { is Activity -> this else -> (this as? ContextWrapper)?.baseContext?.getActivity() } Usage in View class context.getActivity() Decompiled cod...
https://stackoverflow.com/ques... 

Pick a random value from an enum?

... Simple Kotlin Solution MyEnum.values().random() random() is a default extension function included in base Kotlin on the Collection object. Kotlin Documentation Link If you'd like to simplify it with an extension function, try th...
https://stackoverflow.com/ques... 

Gson - convert from Json to a typed ArrayList

...arameters, such as Class<?> or List<? extends CharSequence>. Kotlin: If you need to do it in Kotlin you can do it like this: val myType = object : TypeToken<List<JsonLong>>() {}.type val logs = gson.fromJson<List<JsonLong>>(br, myType) Or you can see this a...