We have already seen that each time we create a new Android project, we also create a new package; this is a kind of container for the code that we write.
We have also learned about and played around with classes. We have imported and taken direct advantage of classes from the Android API, such as Log
and Toast
. We have also used the AppCompatActivity
class but in a different manner to that of Log
and Toast
. You might recall that the first line of code in all our projects so far, after the import
statements, used the :
notation to inherit from a class:
class MainActivity : AppCompatActivity() {
When we inherit from a class, as opposed to just importing it, we are making it our own. In fact, if you take another look at the line of code, you can see that we are making a new class, with a new name, MainActivity
, but basing it on the AppCompatActivity
class from the Android API.