https://github.com/queeniecplusplus/android_review_19
Intent using ShareCompat to share info via Gmail/ SMS
https://github.com/queeniecplusplus/android_review_19
android appcompat intent kotlin share
Last synced: 3 months ago
JSON representation
Intent using ShareCompat to share info via Gmail/ SMS
- Host: GitHub
- URL: https://github.com/queeniecplusplus/android_review_19
- Owner: QueenieCplusplus
- Created: 2021-02-07T03:55:33.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-02-07T05:29:15.000Z (over 4 years ago)
- Last Synced: 2025-01-06T04:26:22.725Z (4 months ago)
- Topics: android, appcompat, intent, kotlin, share
- Language: Kotlin
- Homepage: https://github.com/QueenieCplusplus/QuickGoThru/blob/master/README.md#google-android-kotlin-溫故安卓---計畫復甦
- Size: 2.31 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Android_Review_19
Intent using ShareCompat to share info via Gmail/ SMS1. share
import androidx.core.app.ShareCompat
ShareIntent = ShareCompat.IntentBuilder.from(this)
.setText(getString(R.string.share_text, itemSold, revenue))
.setType("text/plain")
.intent2. data loop
private fun showNowItem(){
// allItems is a listOf array.var newItem = allItems[0]
// Loopfor (i in allItems) {
if (itemSold >= i.startProductionAmount) {
newItem = i // 迴圈的任何元素裝進 newItem 容器中}
else break
}// If the new data is actually different than the current data
// update the data info
if (newItem != nowItem) { // 倘若等號前後不相等則...nowItem = newItem
binding.dessertButton.setImageResource(newItem.imageId)
binding.amountSold = newItem.startProductionAmount
binding.revenue = newItem.price
}}
4. List
// 資料類別確定了資料的型別,倘若呼叫 Item 時。
data class Item (val imageId: Int,
val price: Int,
val amount: Int)
private val allItemFromZero = listOf(
Item(R.drawable.lollipop,55,0),
Item(R.drawable.marchmello, 45,0),
Item(R.drawable.oreo, 38, 0))
5. data opts
private var nowItem = allItems[0]
private var revenue = 0
private var itemSold = 0
//Update the amount & price
revenue += nowItem.price
itemSold++
6. List opt
// 建立集合或是陣列?
data class Item (val imageId: Int,
val price: Int,
val amount: Int)
// 建立集合
private val allItemFromZero = listOf(Item(R.drawable.lollipop,55,0),
Item(R.drawable.marchmello, 45,0),
Item(R.drawable.oreo, 38, 0))
// 建立容器
var newItem = allItemFromZero[0]// 集合方法:隨機()
//也可呼叫 .first() 取值
newItem = allItemFromZero.shuffled().last()LiveData 則屬於泛型資料類別:https://ithelp.ithome.com.tw/articles/10239879 免除為龍蛇雜燴的集合工具做轉型運算的煩惱。
7. output



