Hi! I am a newbie in Kotlin and Android, going thr...
# android
i
Hi! I am a newbie in Kotlin and Android, going through https://developer.android.com/jetpack/compose/tutorial. But it seems for using layouts (and elements such as Row/Column) I need to
import androidx.compose.foundation.layout.Column
package, is it correct? Because in my case I'm getting "Unresolved reference" for Row or Column P.S. Nevermind, it fixed the issue. Strange design idea for me. What if Jetpack-Compose devs want to add new elements in the future? Isn't it better to import the whole layout package once at all?
r
You can replace the last part of an import statement with a star/asterisk
*
to import everything from that package/namespace/etc. https://kotlinlang.org/docs/packages.html#imports I believe that's frowned upon (at the very least, I personally frown upon it) because it hides what is actually being imported from the coder and "floods" your file with extra names. With Java/Kotlin imports, I just import every thing I need individually. Not as friendly for coders as the python import system, IMO, but here we are. IDE's are helpful, though. Jetbrains IDEs let you just do ALT+Enter to import the needed thing, or CTRL+ALT+O to clean up your imports
c
Also, since this is compose specific checkout #compose
i
Thank you! I got used to Python and Kotlin brings a whole bunch of new things for me. I've just finished Harvard's CS50 and chose Kotlin/Android for my final project. Compare to xml/views, I like the idea of making UI in coding way, like with UI frameworks so that's why I chose to learn Compose. I will follow guidelines and import everything individually.
c
nice. i could never get past like lesson 4 of that CS50. Way to go!