Skip to content

5.9. 마이페이지

Seulgi Kim edited this page Jan 15, 2021 · 2 revisions

WrittenBy

구현 방법

(1) RecyclerView를 통해 키워드 Display

  • RecyclerView.Adapter를 상속받은 MyPageKeywordAdapter를 사용

구현 코드

(1) RecyclerView를 통해 키워드 Display

  • fragment_my_page.xml
        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_my_keyword"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_marginTop="20dp"
            tools:listitem="@layout/item_my_page_keyword_list"
            tools:itemCount="4"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/tv_my_keyword" />
  • MyPageFragment.kt
    private fun initRecyclerView() {
        binding.rvMyKeyword.apply {
            adapter = myPageKeywordAdapter
            layoutManager = LinearLayoutManager(context)
            setHasFixedSize(true)
        }
    }

실행 화면