I've just started app making and Java and i got a simple code like this:
package nekocorp.helpdesk;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class Start extends AppCompatActivity {
public static void main(String []args) {
System.out.println("It's a me Mario!");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}
and it only shows the text in the activity_start.xml file as shown here:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="nekocorp.helpdesk.Start">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello Me!" />
</RelativeLayout>
In an Android app, you do not need a main() method like you do in other Java apps. Android uses an event driven model. The first events you must understand are call the "life cycle methods". These are used during different phases of your program, such as creating and destroying it. I suggest you start with this tutorial to help you understand this important part of Android programming.
In addition, there is no "console" where println() can display messages. Instead, you must create a Graphical User Interface (GUI) with different elements that define the look of your app. When you create a new project in Android Studio, select the "Empty Activity" to see an example of an app with a simple "Hello, Android" message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With