https://kotlinlang.org logo
#android
Title
# android
a

ahegazy

05/07/2019, 11:33 AM
Is there a way to write snake case view ids in XML and use camel case variable names for the view in Kotlin while using Kotlin Android extensions plugin? I don’t won’t to break conventions and use camel case as view ids in XML, but it seems that there is no other way
d

dawidhyzy

05/07/2019, 11:35 AM
no, you can use Android Data Binding instead
2
2
a

ahegazy

05/07/2019, 12:12 PM
Would it make sense to only use it for views injection?
d

dawidhyzy

05/07/2019, 12:13 PM
sure
g

ghedeon

05/07/2019, 12:52 PM
You don't want this can of worms, called Databindings. You can easily achieve desired behavior via import aliases: import snake_case_id as camelCaseId. Now, it's an open question if it worth the trouble. A lot of people just switch to camelCase in XML (even Google is not consistent here). Alternatively, some people actually find snake_case in Kotlin useful, because it helps to visually distinguish your views from regular variables.
d

dawidhyzy

05/07/2019, 1:36 PM
Worms?
a

ahegazy

05/07/2019, 2:28 PM
import aliases could make sense if it can be automated somehow, but I think it should have been under the hood
l

louis993546

05/08/2019, 5:10 AM
I think Google just announced like a view binding lib during IO, you can take a look at the keynotes
a

ahegazy

05/08/2019, 9:03 AM
yeah, saw that on Twitter yesterday. but I think it’s not available now… have to check release dates, but that is great news!
@louis993546 I think I saw you yesterday in Google Berlin 🙂 Let’s meet-up next time 😉
3 Views