Android開發筆記一(hello world),androidhello

來源:互聯網
上載者:User

Android開發筆記一(hello world),androidhello

 UI:

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="helloworld"
android:id="@+id/btnEnter"
android:layout_marginTop="96dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:onClick="MyClick"/><!--定義一個單擊事件-->

Code:
import android.view.View;<!--需要匯入-->
public  void MyClick(View v)
{
ShowDialog("Hello world");
}
/*
顯示
*/
private void ShowDialog(String str) {
new AlertDialog.Builder(MainActivity.this)
.setMessage(str)
.show();
}

開發步驟:

1、下載好SDK,這個可以去官網下載,目前最新的5.0,其實當學習來用已經夠了
2、建立一個Andoroid程式,MyAndroidDemo1,拖一個button控制項設定好ID和text,然後到Main主程式裡寫一個MyClick方法,設定button點擊事件選擇MyClick
3、設定模擬器、主題、啟動程式、安卓的版本
4、開啟Tools-Android-AVD Manager,建立一個已經下載的skd版本,然後啟動
5、運行程式,看效果


效果:

如有存在不合適的地方可以與我聯絡,謝謝


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.