https://github.com/queeniecplusplus/android_review_1_app
我的媽祖關公孫悟空卡通版本的抽籤應用程式(看看今日運勢如何,祝你好手氣!)
https://github.com/queeniecplusplus/android_review_1_app
random svg xml
Last synced: 4 months ago
JSON representation
我的媽祖關公孫悟空卡通版本的抽籤應用程式(看看今日運勢如何,祝你好手氣!)
- Host: GitHub
- URL: https://github.com/queeniecplusplus/android_review_1_app
- Owner: QueenieCplusplus
- Created: 2021-01-30T01:28:49.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-30T06:02:16.000Z (over 5 years ago)
- Last Synced: 2025-11-17T11:04:50.752Z (8 months ago)
- Topics: random, svg, xml
- Language: HTML
- Homepage: https://github.com/QueenieCplusplus/QuickGoThru/blob/master/README.md#google-android-kotlin-溫故安卓---計畫復甦
- Size: 19.4 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Android_Review_1_app
我的媽祖關公孫悟空卡通版本的抽籤應用程式(看看今日運勢如何,祝你好手氣!)




* 畫面佈局
* 邏輯撰寫
package com.katepatty.luckyroller
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log.d
import android.widget.ImageView
import android.widget.TextView
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
roller()
}
private fun roller(){
// 宣告容器變數
val outputStr: TextView = findViewById(R.id.rollResultTxt)
val outputImg: ImageView = findViewById(R.id.rollResultImg)
// 生出隨機值
val randomInt = (1..5).random()
// 將隨機值指派給容器變數的屬性中
//outputStr.text = randomInt.toString()
//rollResultTxt. got its method too
val randomTxt = when (randomInt){
1 -> "好運連連"
2 -> "貴人加持"
3 -> "喜憂參半"
else -> "請回府,記得拜拜喔!下次再來玩~"
}
val randomSrc = when (randomInt) {
1 -> R.drawable.notbad
2 -> R.drawable.luck
3 -> R.drawable.gotpower
else -> R.drawable.home
}
// below resId = 容器變數放回呼值
outputImg.setImageResource(randomSrc)
outputStr.setText(randomTxt)
}
}