ClassCastException when Referencing String Value

18 views
Skip to first unread message

Pete Doherty

unread,
Apr 6, 2015, 1:15:03 PM4/6/15
to clojure...@googlegroups.com
Hi all,

I'm seeing a ClassCastException: Integer cannot be cast as CharSequence when trying to do the following:

(on-ui (toast (*a) org.stuff.events.R$string/app_name))

Is there some additional casting/conversion that needs to be done to the value before it can be used as a string? That string value does exist and I'm able to use it elsewhere (e.g. as a text view text attribute).

Thanks!

Adam Clements

unread,
Apr 6, 2015, 2:04:10 PM4/6/15
to clojure...@googlegroups.com

That *is* an integer,  the constant in the R classes is a resource reference. You need to either pass it to something which accepts a resource id, or use one of the resource get string methods to access the appropriate string.


--
You received this message because you are subscribed to the Google Groups "clojure-android" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-android+unsubscribe@googlegroups.com.
To post to this group, send email to clojure-android@googlegroups.com.
Visit this group at http://groups.google.com/group/clojure-android.
For more options, visit https://groups.google.com/d/optout.

Alexander Yakushev

unread,
Apr 6, 2015, 3:26:49 PM4/6/15
to clojure...@googlegroups.com

Adam is right, it's just that toast fiction does not accept resource ID. I might add that behavior someday, meanwhile you can use neko.resource/get-string function to extract the string for the ID.


To unsubscribe from this group and stop receiving emails from it, send an email to clojure-andro...@googlegroups.com.
To post to this group, send email to clojure...@googlegroups.com.

Pete Doherty

unread,
Apr 8, 2015, 11:34:00 PM4/8/15
to clojure...@googlegroups.com
Feeding the resource ID to `neko.resource/get-string` worked perfectly.

Thanks, everyone!


On Monday, April 6, 2015 at 3:26:49 PM UTC-4, Alexander Yakushev wrote:

Adam is right, it's just that toast fiction does not accept resource ID. I might add that behavior someday, meanwhile you can use neko.resource/get-string function to extract the string for the ID.


On Mon, Apr 6, 2015, 21:04 Adam Clements <adam.c...@gmail.com> wrote:

That *is* an integer,  the constant in the R classes is a resource reference. You need to either pass it to something which accepts a resource id, or use one of the resource get string methods to access the appropriate string.


On Mon, 6 Apr 2015 6:15 pm Pete Doherty <pdohe...@gmail.com> wrote:
Hi all,

I'm seeing a ClassCastException: Integer cannot be cast as CharSequence when trying to do the following:

(on-ui (toast (*a) org.stuff.events.R$string/app_name))

Is there some additional casting/conversion that needs to be done to the value before it can be used as a string? That string value does exist and I'm able to use it elsewhere (e.g. as a text view text attribute).

Thanks!

--
You received this message because you are subscribed to the Google Groups "clojure-android" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-andro...@googlegroups.com.
To post to this group, send email to clojure...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojure-android.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages