Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Oh I once forgot to parse an int before using the value for a TextView, guess the system didn't like that lol
-
dannydam3217yOh cut it with the shit posts...TextView.setText() expects a string to be passed as a parameter, not an integer.
-
Bikonja23867y@dannydam still, you'd expect a compiler error or at least the runtime error saying that String is expected.
I do like that you can directly use a resource id, but in a case like this it can definitely cause confusion. -
dannydam3217y@Bikonja I do think that Google should've added some idiot proofing to setText by making another setText() function in the TextView class that takes int as a parameter and parses it. Nevertheless, anyone who's been programming in Android for more than 5 minutes knows that you're supposed to pass a string to TextView. You can always look up the documentation (Android Studio even has an option to show documentation on mouse hover).
-
Pointer32497y@Bikonja
I hope to be not mistaken, but Android resources are Integers, that's why the method supports Integers. If you use localization, you'll end up using constants from the resource file, not strings directly.
Because OOP enables polymorphism and other shit. Please, get your facts straight. -
Bikonja23867y@apex that's exactly what I'm saying, it's nice that there's an overload for resources, but because resources are nothing more than ints you have confusion as there's a chance you might accidentally pass in an int when you wanted to show the actual number, but if resources were standalone objects you'd have a resource overload as opposed to the int overload and then there's far less of a chance for accidental usage of the resource overload.
Again, I do like the functionality and I agree that after a very short time with Android development you realise your mistake easily, but you can't deny that it's a bit confusing when you first get this situation. -
Pointer32497y@Bikonja Yeah, for starters you're like "Man, this is awesome", then you understand how everything is wired up and BAM, facepalm to yourself, hahaha
-
@dannydam what is this dumbass language that requires me to explicitly convert an integer to string?
-
Pointer32497y
-
Pointer32497y@isaacWeisberg If you're asking for the language the OP it's talking about, it's Java. Otherwise, I don't know what are you talking about
Related Rants
Gotta love android.
int a;
//do stuff
textView.setText(a);
....
ResourceNotFoundException
undefined
android