Any tricks that you maybe use to hide this long as...
# android
g
Any tricks that you maybe use to hide this long ass styleable ids in your custom classes?
stackoverflow 1
g
You can import them using
as
syntax with custom name
👍 1
r
or better yet , use data binding ,BindingAdapters instead lol
Although you create those names, why not just make it shorter lol
g
you can't be serious. I create only attribute name (
currencyTextColor
), the rest of the prefix is generated by android. I'm not saying it's a vital problem, but something like
attrs.getColor(theme[currencyTextColor])
is a bit cleaner then
attrs.getColor(R.styleable.BlahBlahLoremIpsum_Whatever_currencyTextColor)
.
It's a very verbose chunk of text in your class that is not real code. I guess I'll just accept it or play with aliases. Thank you all!
r
Well the prefix is the declare-styleable name you give it in XML. Which is normally the name of the widget. It's not like its magically generated by android. Creating a map or alias really is not useful, also its abit not as clean design wise if you really think about it. Besides you literally just saving them to local variables anyway
Short code isnt always better code lol. My vote is to keep it as is. It's already understood industry wise. For instance if I'm a new dev , I look at this code I know exactly what your doing. The prefix tells me exactly where I need to look in xml to declare change. If I'm new to it , I can refer directly to develop.android documentation without having to consider why you made implementation changes.