1. 程式人生 > >Hello world代碼解釋

Hello world代碼解釋

world! undle bundle you edi show tex activity utf

<xml>

<?xml version="1.0" encoding="utf-8"?>

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"

android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
br/>xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
br/>tools:showIn="@layout/activity_main">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
/>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
其中,wrap_content為強制擴充來顯示textview中的內容
<MainActivity>
package com.mycompany.helloworld;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends AppCompatActivity {//寫方法時繼承自Activity@Override//偽代碼,表示方法重寫
br/>@Override//偽代碼,表示方法重寫
super.onCreate(savedInstanceState);
//調用Activity的onCreate方法,和Activity必須搭配使用
setContentView(R.layout.activity_main);//setContentView將Activity與xml可視化文件關聯的代碼
}
}

Hello world代碼解釋