리스트뷰 아이템 클릭 잘 안되네요.ㅠ.ㅠ
411
작성한 질문수 5
게시글 보기 페이지 공부하고 있어요
응용해서 만들고 있는데요

리스트뷰 아이템 글릭 코딩에서 에러가 나와요
context이부분이 계속 빨간색으로 나오더라구요
import 해도 저렇게 뜨구요
problems 에서는
Unresolved reference : context
이렇게 뜨네요.. 흠.. 잘모루겠어요
도와주세요
답변 4
0
ImdaeListActivity
import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import com.example.mymemul.ListTextView.ImdaeListModel
import com.example.mymemul.R
import com.example.mymemul.Todo.ImdaeListRvAdapter
import com.example.mymemul.databinding.ActivityImdaeListBinding
import com.example.mymemul.util.FBAuth
import com.example.mymemul.util.FBRef
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.ktx.auth
import com.google.firebase.database.DataSnapshot
import com.google.firebase.database.DatabaseError
import com.google.firebase.database.ValueEventListener
import com.google.firebase.ktx.Firebase
class ImdaeListActivity : AppCompatActivity() {
private lateinit var auth: FirebaseAuth
private val imdaeDataList = mutableListOf<ImdaeListModel>()
// private val ImdaeKeyList = mutableListOf<String>()
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)
binding = ActivityImdaeListBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)
auth = Firebase.auth
binding.imdaeListBtn.setOnClickListener {
val intent = Intent(this, ImdaeSaActivity::class.java)
startActivity(intent)
}
imdaeListAdapter = ImdaeListRvAdapter(imdaeDataList)
binding.imdaeListView.adapter = imdaeListAdapter
binding.imdaeListView.setOnItemClickListener { parent, view, position, id ->
val intent = Intent(context, ImdaeSsbActivity::class.java)
startActivity(intent)
}
//임대 리스트
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!!)
// ImdaeKeyList.add(dataModel.key.toString())
}
imdaeListAdapter.notifyDataSetChanged()
}
override fun onCancelled(databaseError: DatabaseError) {
Log.w(TAG, "loadPost:onCancelled", databaseError.toException())
}
}
var uid = FBAuth.getUid()
FBRef.user
.child("Imdae")
.child(uid)
.addValueEventListener(postListener)
}
}ImdaeSaActivity
class ImdaeSaActivity : AppCompatActivity() {
private val TAG = ImdaeSaActivity::class.java.simpleName
private lateinit var auth: FirebaseAuth
private var mEtAddress: EditText? = null
// private val data = arrayListOf<ImdaeTodo>()
private lateinit var binding: ActivityImdaeSaBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// setContentView(R.layout.activity_imdae_sa)
binding = DataBindingUtil.setContentView(this, R.layout.activity_imdae_sa)
auth = Firebase.auth
// auth = FirebaseAuth.getInstance()
// binding = ActivityImdaeListBinding.inflate(layoutInflater)
// val view = binding.root
// setContentView(view)
binding.imdaeBtn.setOnClickListener {
val uid = auth.currentUser?.uid.toString()
val mulgun = binding.mulgunall.text.toString()
val sename = binding.sename.text.toString()
val sephone = binding.sephoneno.text.toString()
val address = binding.etAddress.text.toString()
val address1 = binding.etAddress1.text.toString()
val bojung = binding.bojung.text.toString()
val worldse = binding.worldse.text.toString()
val kwanry1 = binding.kwanry1.text.toString()
val kwanry2 = binding.kwanry2.text.toString()
val mjbb = binding.myungjuk.text.toString()
val cgbb = binding.chunggo.text.toString()
val time = FBAuth.getTime()
Log.d(TAG, sename)
Log.d(TAG, sephone)
FBRef.user
.child("Imdae")
.child(uid)
.push()
.setValue(
ImdaeitemModel(mulgun,sename,sephone,address,address1,
bojung,worldse,kwanry1,kwanry2,mjbb,cgbb, time)
)
Toast.makeText(this,"임대자료 입력완료", Toast.LENGTH_LONG).show()
finish()
}
}
}ImdaeListRvAdapter
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 mulgun = view?.findViewById<TextView>(R.id.mul)
val sename = view?.findViewById<TextView>(R.id.sename12)
mulgun!!.text = imdaeDataList[position].mulgun
sename!!.text = imdaeDataList[position].sename
return view!!
}
}ImdaeListModel
class ImdaeListModel (
val mulgun: String = "",
val sename: String = "",
)activity_imdae_list
<layout>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".List.ImdaeListActivity">
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFD968"
android:orientation="vertical">
<TextView
android:id="@+id/imdaetitle"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:background="#FFD968"
android:gravity="center_horizontal|center_vertical"
android:text="임 대"
android:textSize="20sp"
android:textColor="#704300"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="5dp"
android:background="@drawable/mocer_call_mulback1"
android:gravity="center_horizontal|center_vertical"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
android:text="No"
android:textSize="20dp" />
<LinearLayout
android:layout_width="2dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:background="@color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
android:text="날짜"
android:textSize="20dp" />
<LinearLayout
android:layout_width="2dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:background="@color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
android:text="세입자"
android:textSize="20dp" />
<LinearLayout
android:layout_width="2dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:background="@color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
android:text="주 소"
android:textSize="20dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="보증금"
android:textSize="20dp" />
<LinearLayout
android:layout_width="2dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:background="@color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="월세"
android:textSize="20dp" />
<LinearLayout
android:layout_width="2dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:background="@color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="관리비"
android:textSize="20dp" />
<LinearLayout
android:layout_width="2dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:background="@color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="권리금"
android:textSize="20dp" />
<LinearLayout
android:layout_width="2dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:background="@color/black" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="면적"
android:textSize="20dp" />
</LinearLayout>
</LinearLayout>
<ListView
android:id="@+id/imdaeListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp" />
</LinearLayout>
<ImageView
android:id="@+id/imdaeListBtn"
android:layout_width="55dp"
android:layout_height="55dp"
android:layout_marginBottom="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/pen"
android:elevation="20dp"
app:layout_constraintBottom_toBottomOf="@+id/linearLayout2"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>activity_imdae_ssb
<layout>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".List.ImdaeSsbActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
이미지가 기본이미지인지 확인
0
132
1
NavController error 발생
0
141
1
fragment 생성하고 메인에서 불러왔는데 안뜹니다.
0
141
2
67강 댓글
0
100
2
7강 데이터바인딩 에러
0
116
2
Firebase 스토리지 유료화 문제
1
297
2
게시글 이미지가 파이어베이스에 저장되지 않습니다.
0
181
2
AVD 갤러리에 이미지 저장 안되는 문제
0
241
2
이미지 받아오는 방법?
0
204
2
회원탈퇴 기능을 추가하려고 합니다.
0
188
2
상태바 질문 드립니다.
0
111
1
섹션2 인트로 페이지 꾸미기 질문 드립니다.
0
110
1
게시판 글을 길게 쓸경우
0
124
2
로그인 로그아웃
0
177
2
갤럭시 연결시 게시판에 업로드한 사진이 보이지 않아요.
0
207
2
웹뷰 AVD 실행안됨
0
191
1
자막켜기가 안되요 ㅜ.ㅜ
1
185
1
리사이클러뷰, 그리드레이아웃 오류
0
186
2
리사이클러뷰 오류 해결 방법이 궁금합니다.
0
194
1
firebase 스마트폰으로 연결이 안되는데 원인이 있을까요
0
259
2
안드로이드 스튜디오 게시글 이미지 업로드 유무
0
217
1
firebase 설정 오류
0
304
2
홈 화면 커뮤니티
0
178
1
게시판 글 읽기
0
240
2





