Android Views and button textedit usage

今天要寫的程式是計算1+2+…+(n-1)+n=?
要用到的東西有:
1.edittext
2.button



很簡單的程式,重點是在如何取得user輸入的資料,以及edittext的使用.

首先,要先了解 TextView, EditText, and Button, the XML layout file (main.xml)格式:


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
   >
<TextView
    android:id="@+id/txtDemo"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    />
<EditText
    android:id="@+id/eTxtDemo"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    />
<Button
    android:id="@+id/btnDone"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Log it"
    />
LinearLayout>

 --------------------------------
然後是Button建置步驟:

1.建立Layout: /res/layout/main.xml
<Button android:id=“@+id/btn_Button” />
2.Main app
onCreate()
findViewById(R.id.btn_Button)
SetOnClickListener()
onClick()
Intent(): setClass(this, .class)
startActivity()
3.Sub app layout: /res/layout/sub_app.xml
4.Sub app code:
onCreate()
findViewById(R.id.btn_Click)
SetOnClickListener()
onClick()
setTitle()
5.AndroidManifest.xml
宣告application的設定值

留言

這個網誌中的熱門文章

最爛的銀行服務-玉山銀行

Mark App Design Apps - Terms and Privacy Policy (服務條款,隱私權政策)

SMR疊瓦式hdd致命缺陷被解決????!!!

ios app 上架時app icon要注意事項

更改google drive預設存放目錄位置Change Google Drive Default Folder Location in Windows

google play 正式發布前測試報告...非常好用.

舊有app在Android 12 閃退問題& app Splash screens

app bundle and bundletool. 關於aab安裝問題

關於google play console app應用程式簽署

Google Play badge徽章產生器