답변 3
1
해결 됬습니다. 신경써주셔서 감사합니다.
이부분이 문제 였네요.. ^^ ㅎㅎ
FBRef.user
.child("Imdae")
.child(uid)
.addValueEventListener(postListener)
0
응용해서 만들어보고 있는데요
RVadapter
class ImdaeListRvAdapter (val imdaeDataList : MutableList<ImdaeListModel>) : BaseAdapter() {
override fun getCount(): Int {
return imdaeDataList.size
}
override fun getItem(position: Int): Any {
return imdaeDataList[position]
}
override fun getItemId(position: Int): Long {
return position.toLong()
}
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
var view = convertView
if (view == null) {
view = LayoutInflater.from(parent?.context).inflate(R.layout.activity_imdae_list_adapter,parent, false)
}
val sename = view?.findViewById<TextView>(R.id.sename12)
val sephone = view?.findViewById<TextView>(R.id.sephone12)
val address = view?.findViewById<TextView>(R.id.imdaeaddress22)
val kwanly = view?.findViewById<TextView>(R.id.imdaekwan11)
val bojung = view?.findViewById<TextView>(R.id.imdaebo11)
val worlse = view?.findViewById<TextView>(R.id.imdaeworl11)
val mjbb = view?.findViewById<TextView>(R.id.imdaemyung11)
sename!!.text = imdaeDataList[position].sename
sephone!!.text = imdaeDataList[position].sephone
address!!.text = imdaeDataList[position].address
kwanly!!.text = imdaeDataList[position].kwanry
bojung!!.text = imdaeDataList[position].bojung
worlse!!.text = imdaeDataList[position].worldse
mjbb!!.text = imdaeDataList[position].mjbb
return view!!
}
}
ListActivity
class ImdaeListActivity : AppCompatActivity() {
private lateinit var auth: FirebaseAuth
private val imdaeDataList = mutableListOf<ImdaeListModel>()
private val TAG = ImdaeListActivity::class.java.simpleName
private lateinit var binding: ActivityImdaeListBinding
private lateinit var imdaeListAdapter : ImdaeListRvAdapter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.activity_imdae_list)
auth = Firebase.auth
binding.imdaeListBtn.setOnClickListener {
val intent = Intent(this, ImdaeSaActivity::class.java)
startActivity(intent)
}
imdaeListAdapter = ImdaeListRvAdapter(imdaeDataList)
binding.imdaeListView.adapter = imdaeListAdapter
//임대 리스트
getImdaeListData()
}
private fun getImdaeListData(){
val postListener = object : ValueEventListener {
override fun onDataChange(datasnapshot: DataSnapshot) {
imdaeDataList.clear()
for (dataModel in datasnapshot.children) {
Log.d(TAG, dataModel.toString())
val item = dataModel.getValue(ImdaeListModel::class.java)
imdaeDataList.add(item!!)
}
imdaeListAdapter.notifyDataSetChanged()
Log.d(TAG, imdaeDataList.toString())
}
override fun onCancelled(databaseError: DatabaseError) {
Log.w(TAG, "loadPost:onCancelled", databaseError.toException())
}
}
FBRef.user.addValueEventListener(postListener)
}
}
ListModel
class ImdaeListModel (
val sename: String = "",
val sephone: String = "",
val address: String = "",
val address1: String = "",
val kwanry: String = "",
val bojung: String = "",
val worldse: String = "",
val mjbb: String = "",
)
FBRef
class FBRef {
companion object {
private val database = Firebase.database
val user = database.getReference("userInfo")
}
}
스크린샷
열심히 살펴봤는데 원인을 알수가 없네요...ㅠ.ㅠ
0