Postingan lainnya
Menghitung jumlah semua (sum) nilai dari child "total", kotlin firebase
https://drive.google.com/open?id=1kKralGYGdZuimkrxxIGaRMH8OI6-D_gJ https://drive.google.com/open?id=1IJ9RQIxOkuw17rKU5TJp7SlyPJRjK_-p
idperiod?.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(p0: AdapterView<*>?, p1: View?, p2: Int, p3: Long) {
val periode = idperiod.selectedItem.toString()
idsearch.setOnClickListener {
val mdatabase = FirebaseDatabase.getInstance().getReference("Transaction").orderByChild("periode")
.startAt(periode).endAt(periode + "\uf8ff")
mdatabase.addValueEventListener(object : ValueEventListener {
override fun onCancelled(p0: DatabaseError) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun onDataChange(p0: DataSnapshot) {
var sum = 0
p0.children.forEach {
val total = it.getValue(transaction::class.java)?.total
val pValue = total?.toInt()
sum += pValue!!
}
idTotal.text = sum.toString()
}
})
}
}
2
Tanggapan
cek aturan main bagiamana cara menampilkan gambar, berikan penjelas di atas, masaahnya apa? kode kamu kenapa? coba diedit lagi