I am trying to set text in a edittext but it says Type mismatch Required Editable found string my code is as follow
String name = "Paramjeet"
val nametxt = findViewById (R.id.nametxt) as EditText
nametxt.text = name
Dont say to use SetText because i am using kotlin not java
Look at the API of EditText:
void setText (CharSequence text, TextView.BufferType type)
Editable getText ()
Link: https://developer.android.com/reference/android/widget/EditText.html
Use
setText(String)
asEditText.text
requires aneditable
at firstplace not StringWHY ?
Nice explanation by Michael given under this link. Do visit this link for more detail
When generating a synthetic property for a Java getter/setter pair Kotlin first looks for a getter. The getter is enough to create a synthetic property with a type of the getter. On the other hand the property will not be created if only a setter presents.
When a setter comes into play property creation becomes more difficult. The reason is that the getter and the setter may have different type. Moreover, the getter and/or the setter may be overridden in a subclass.