<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 嵌入式系統 > 設計應用 > 建立Android開(kāi)發(fā)環(huán)境

建立Android開(kāi)發(fā)環(huán)境

作者: 時(shí)間:2016-10-08 來(lái)源:網(wǎng)絡(luò ) 收藏

public class HelloChina extends Activity {

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle icicle) {

super.onCreate(icicle);

//setContentView(R.layout.main);

TextView tv = new TextView(this);

tv.setText(這是一個(gè)測試Android的helloWorld);

setContentView(tv);

}

}在類(lèi)前面添加import android.widget.TextView;(Java 中的概念,不多做介紹)

在A(yíng)ndroid 中,用戶(hù)界面控件被封裝成了各種Class叫做Views。一個(gè)View 是一個(gè)可以顯示的控件對象,比如RadioButton,Animation,TextLable 等。其中的一個(gè)簡(jiǎn)單的控件是TextView:

TextView tv = new TextView(this);

傳入TextView構造函數的參數是一個(gè) Context 對象,通過(guò)這個(gè)對象可以使用系統提供的功能接口,比如加載資源,訪(fǎng)問(wèn)數據庫和共享數據等等。Activity類(lèi)從Context 類(lèi)繼承而來(lái),所以Activity本身是一個(gè)Context(Java中的繼承概念)。

TextView 對象構建以后就可以設置要顯示的數據了。

tv.setText(這是一個(gè)測試Android的helloWorld);

最后是連接TextView到屏幕, 類(lèi)似這樣:

setContentView(tv);

setContentView() 方法可以控制具體哪一個(gè)控件和系統的 UI 聯(lián)系起來(lái)(我的理

解是設置為主顯示View)。如果沒(méi)有設置,屏幕中將會(huì )顯示空白。

運行程序: Hello, Android

點(diǎn)擊Run 就可以看到如下的窗口(如何配置啟動(dòng)參數,參考前面)

模擬器啟動(dòng)起來(lái),應用程序啟動(dòng)起來(lái)了。

建立AndRoid開(kāi)發(fā)環(huán)境

上一頁(yè) 1 2 下一頁(yè)

關(guān)鍵詞:

評論


技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>