private val userID by lazy {
intent.getStringExtra(EXTRA_ID) ?: "hong_gildong"
}
현재 로그인 한 유저의 아이디를 가져오는데 받은 아이디 안에는 가입했던 정보가 다 들어있다.
private fun setViewMore(contentTextView: TextView, viewMoreTextView: TextView) {
contentTextView.post {
val lineCount = contentTextView.layout.lineCount
if (lineCount > 0) {
if (contentTextView.layout.getEllipsisCount(lineCount - 1) > 0) {
// 더보기 표시
viewMoreTextView.visibility = View.VISIBLE
// 더보기 클릭 이벤트
viewMoreTextView.setOnClickListener {
contentTextView.maxLines = Int.MAX_VALUE
viewMoreTextView.visibility = View.GONE
info.setMovementMethod(ScrollingMovementMethod())
}
} else {
viewMoreTextView.visibility = View.GONE
}
}
}
}
<TextView
android:id="@+id/tv_myinfo"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginStart="150dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="24dp"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/introduction"
android:textSize="15sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_id" />
<TextView
android:id="@+id/view_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:text="@string/more"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_myinfo" />
character1.isVisible = false
character2.isVisible = false
character3.isVisible = false
if (loginUser.character.size != 0) {
if (loginUser.character.size == 1) {
character1.isVisible = true
val userCharacter1 = loginUser.character[0]
character1.text = userCharacter1
} else if (loginUser.character.size == 2) {
character1.isVisible = true
character2.isVisible = true
val userCharacter1 = loginUser.character[0]
val userCharacter2 = loginUser.character[1]
character1.text = userCharacter1
character2.text = userCharacter2
} else if (loginUser.character.size == 3) {
character1.isVisible = true
character2.isVisible = true
character3.isVisible = true
val userCharacter1 = loginUser.character[0]
val userCharacter2 = loginUser.character[1]
val userCharacter3 = loginUser.character[2]
character1.text = userCharacter1
character2.text = userCharacter2
character3.text = userCharacter3
}
for (index in 0 until min(5, myPostIDList.size)) {
//표시할 게시물 ID
val postID = myPostIDList[myPostIDList.size - 1 - index]
//게시물이 표시될 postItem 레이아웃
val postItem = myPostItemList[index]
myPostItemIDMap[postItem.id] = postID
setPostItemUI(postItem, postID)
}
for (postItem in myPostItemList) {
//게시글 클릭 이벤트 처리하기
postItem.setOnClickListener {
val postID = myPostItemIDMap[postItem.id]!!
Log.d(TAG, "post item clicked) post id: ${postID}")
if (postID == -1) return@setOnClickListener
goToDetail(postID)
}
private fun goToDetail(postID: Int) {
//로그인한 회원 ID와 게시물 ID 전달하며, 디테일 화면으로 이동
val detailIntent = Intent(this, DetailPageActivity::class.java).apply {
putExtra("userID", userID)
putExtra("postID", postID)
//마이페이지에서 디테일 화면을 시작했음을 전달
putExtra("activityName", "MyPage")
}
startActivity(detailIntent)
}
<include layout="@layout/mypage_post_layout" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/view_post"
android:layout_width="120dp"
android:layout_height="180dp"
android:layout_marginRight="30dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/pt_image"
android:layout_width="120dp"
android:layout_height="120dp"
android:src="@drawable/hikers_icon_small_grey"
android:scaleType="centerInside"
android:padding="20dp"
android:background="@color/light_grey"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pt_image">
<TextView
android:id="@+id/tv_post_title"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/post_title"
android:textSize="15sp"
android:textStyle="bold"
tools:layout_editor_absoluteX="36dp"
tools:layout_editor_absoluteY="180dp" />
<TextView
android:id="@+id/tv_post_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="@string/post_writer_name"
android:textColor="#6E6E6E"
android:textSize="10sp"
tools:layout_editor_absoluteX="36dp"
tools:layout_editor_absoluteY="180dp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>