EditText med allt annat än strängar

Det här förbryllade mig ett tag. Jag försökte sätta ett värde i en EditText och fick glada skutt från logcat:en

E/AndroidRuntime( 3712): java.lang.RuntimeException: Unable to start activity ComponentInfo{se.sigtuna.android.uvbaisk/se.sigtuna.android.uvbaisk.UvbaiskQuestions1Activity}: android.content.res.Resources$NotFoundException: String resource ID #0x0
E/AndroidRuntime( 3712): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0

Det tog mig ca tjugo minuter att till slut prova

editText.setText(String.valueOf(myObject.intId))

istället för

editText.setText(myObject.intId)

Så, kids. Se till att bara, bara, BARA skicka in strängar till en EditText, oavsett om logcat vill säga att den saknar en resurs, likt det som kan hänta om man anger tex en widget som tillhör en annan aktivitet än den som syns just nu……


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

If you’d like to utilise the power of Webmentions do the following:
1: Create a post or something as a response to this one and make sure that the response contains this posts permalink URL (protip: copy and paste it from your browser)
3: Copy and paste the URL from your response in the field below and click Ping Me! 3: Wait for the moderation gnomes to do their work.
4: Done!