大约有 366 项符合查询结果(耗时:0.0461秒) [XML]
On showing dialog i get “Can not perform this action after onSaveInstanceState”
...d call commitAllowingStateLoss() on Transaction object. Here is example in Kotlin:
override fun show(manager: FragmentManager?, tag: String?) {
try {
val ft = manager?.beginTransaction()
ft?.add(this, tag)
ft?.commitAllowingStateLoss()
} catch (ig...
How to create EditText with cross(x) button at end of it?
...
This is a kotlin solution. Put this helper method in some kotlin file-
fun EditText.setupClearButtonWithAction() {
addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(editable: Editable?) {
...
How to hide a View programmatically?
...
Kotlin Solution
view.isVisible = true
view.isInvisible = true
view.isGone = true
// For these to work, you need to use androidx and import:
import androidx.core.view.isVisible // or isInvisible/isGone
Kotlin Extension Sol...
Android set height and width of Custom view programmatically
...
On Kotlin you can set width and height of any view directly using their virtual properties:
someView.layoutParams.width = 100
someView.layoutParams.height = 200
...
Do I need all three constructors for an Android custom view?
...
Kotlin seems to take away a lot of this pain:
class MyView
@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0)
: View(context, attrs, defStyle)
@JvmOverloads will generate all re...
How to set custom header in Volley Request
...
In Kotlin,
You have to override getHeaders() method like :
val volleyEnrollRequest = object : JsonObjectRequest(GET_POST_PARAM, TARGET_URL, PAYLOAD_BODY_IF_YOU_WISH,
Response.Listener {
// Success ...
How to find out which view is focused?
...
kotlin: in fragment - activity?.currentFocus
– Mohammad Reza Khahani
Nov 16 '19 at 11:12
add a comme...
Android equivalent to NSNotificationCenter
...
Kotlin: Here's a @Shiki's version in Kotlin with a little bit refactor in a fragment.
Register the observer in Fragment.
Fragment.kt
class MyFragment : Fragment() {
private var mContext: Context? = null
private...
How to check if an intent can be handled from some activity?
...
Using Kotlin If you need to do something when intent is not available,
fun isIntentAvailable(context: Context, action: String?): Boolean {
val packageManager = context.packageManager
val intent = Intent(action)
val reso...
Mockito: InvalidUseOfMatchersException
...
This helped in figuring out why my kotlin code would give me error, cuz all methods in kotlin are final!
– sorry_I_wont
Jul 2 '19 at 3:28
...