99re热这里只有精品视频,7777色鬼xxxx欧美色妇,国产成人精品一区二三区在线观看,内射爽无广熟女亚洲,精品人妻av一区二区三区

Android Activity

2018-02-18 17:34 更新

Activity顯示應(yīng)用程序的用戶界面,其可以包含諸如按鈕,標(biāo)簽,文本框等小部件。

通常,你使用XML文件定義UI,例如位于項(xiàng)目的 res/layout 文件夾中的main.xml文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

      <TextView
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="hello" />

</LinearLayout>

在運(yùn)行時(shí),使用Activity類的setContentView()方法,在Activity類的onCreate()方法
處理程序中加載XML UI:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}

在編譯期間,XML文件中的每個(gè)元素都將被編譯為其等效的Android GUI類,其中的屬性由方法表示。

然后,Android系統(tǒng)在加載Activity時(shí)創(chuàng)建Activity的UI。

上面的代碼生成以下結(jié)果。

Android Activity



以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)