• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

MainActivity setup creates different code on startup

JXWD

Lurker
Hi just setting out need a little pointer please...

One I go though all the setup in android studio 3.1.2 I get:

package com.example.simplelogin

...
class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}



Where as all the tutorials I open start something like below:

is this the equivalent? why is it different? Thanks -Hagen



package com.example.sairamkrishna.myapplication;

...


public class MainActivity extends Activity {


@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

}
 
The difference is because you have created a project using the Kotlin programming language, as opposed to Java.

The example code you're seeing is different, because that code is Java. If you recreate the project, using the Java option, the example should be just about the same as your code.
 
Back
Top Bottom