Pleas help me i have problem in my project


#1

hello friends

at my project i get this problem

what is solution


#2

Kotlin is usually good at allowing you to call properties defined in Java using the getName/setName convention in Kotlin using the property syntax of “.name”.

However TextView (which is the superclass of EditText) defines overloads of setText so the type has these methods:

getText()
setText(int resid)
setText(CharSequence text)
setText(CharSequence text, TextView.BufferType type)
setText(int resid, TextView.BufferType type)
setText(char[] text, int start, int len)

With all these variations on setText Kotlin doesn’t think that text is a standard Java property and doesn’t allow you to access it as “.text” and you have to fall back to calling getText and setText methods.

Some Kotlin libraries may help work around this by defining alternately named extension properties, but in this case you will probably just need to use getText and setText methods.


#3

how can i use this
i try instead text do gettext and set text but no solution good


#4

So the first error line replace “.text” with “.getText()”. The other line you replace “.text = value” with “.setText(value)”


#5

The problem is an import problem. Look carefully and you will see that etUserYearOfBirth is a resource Id. Because you are importing all resource Id’s into the namespace this will be resolved as a resourceId (integer).

What you probably intended to do was to use the Kotlin android extensions instead. You will have to make sure that they are enabled in your gradle file and remove the import of the id constants (this import is probably problematic, you should normally use R.id.* explicitly to avoid exactly the problem you’re having now).


#6

sorry friend iam new in this field can u explain for me step by step …


#7

The linked article provides instructions in quite some detail. You should attempt to follow them. In short however do the following:

  • remove the offending import.
  • Add the extensions plugin in your build.gradle file
  • import the synthetic extension names into your activity file (the ide should actually make this easy for you)

#8

Follow this article How Does Kotlin Generate Property from Java Getters and Setters (Undocumented by Jetbrains)