Android基礎(chǔ)

1,

我們提供的服務(wù)有:網(wǎng)站建設(shè)、成都網(wǎng)站建設(shè)、微信公眾號(hào)開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、新余ssl等。為上千家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的新余網(wǎng)站制作公司

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);#任何的項(xiàng)目都需要覆寫父類的onCreate方法

setContentView(R.layout.activity_main);#顯示出你所定義的布局,或指在當(dāng)前活動(dòng)中加載你所需要的布局

}

2,創(chuàng)造加載布局 res/layout/new/android xml file

Android基礎(chǔ)

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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"//讓當(dāng)前元素變得和父類一樣寬

    android:layout_height="match_parent"

    android:orientation="vertical" >布局是垂直的,添加文件只能垂直添加

    <Button

        android:id="@+id/button1"//添加一個(gè)按鈕

        android:layout_width="match_parent"

        android:layout_height="wrap_content"//只能包裹住文字

        android:text="Button" />

</LinearLayout>

3,

       @Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);//隱藏標(biāo)題欄

setContentView(R.layout.first_layout);

}

4,

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);//隱藏標(biāo)題欄

setContentView(R.layout.first_layout);

Button button1 = (Button) findViewById(R.id.button1);

button1.setOnClickListener(new OnClickListener() {//創(chuàng)造一個(gè)按鈕的監(jiān)聽器,點(diǎn)擊會(huì)有響應(yīng),如果出現(xiàn)錯(cuò)誤,點(diǎn)擊//ctrl+shift+o即可

@Override

public void onClick(View v) {

// TODO 自動(dòng)生成的方法存根

Toast.makeText(getApplicationContext(), "you clicked button1", Toast.LENGTH_SHORT).show();

}

});

}

網(wǎng)站標(biāo)題:Android基礎(chǔ)
本文路徑:http://muchs.cn/article30/ghecso.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、自適應(yīng)網(wǎng)站、網(wǎng)站設(shè)計(jì)公司服務(wù)器托管動(dòng)態(tài)網(wǎng)站、

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化