[fpc-devel] FPC-JVM: Problem with String => CharSequence
Sven Barth
pascaldragon at googlemail.com
Sat Aug 27 12:00:26 CEST 2011
Hello together!
Now that the cycle problem was solved (I don't know whether it works,
because I'm still trying to get a test working ^^), I've encountered the
next problem. The android.widget.TextView class has a method setText
that takes a CharSequence which is implemented by java.lang.String. As
I've read in the wiki UnicodeString is mapped to that type. But the
following code pieces don't compile (tv is the TextView of type AWTextView):
=== source begin ===
tv.setText('Hello World'); // Incompatible type for arg no. 1: Got
"Constant String", expected "LongInt"
var
s: UnicodeString;
s := 'Hello World';
tv.setText(s); // Incompatible types: got "UnicodeString" expected
"JLCharSequence"
var
s: UnicodeString;
c: JLCharSequence;
s := 'Hello World';
c := s;
tv.setText(c); // Incompatible types: got "UnicodeString" expected
"JLCharSequence"
// the following works though
var
s: JLString;
s := 'Hello World';
tv.setText(s);
=== source end ===
Can it be that the compiler doesn't check for the interfaces implemented
by the mapped string type?
Regards,
Sven
More information about the fpc-devel
mailing list