→ 파싱까지 끝낸 데이터를 어떻게 화면에 띄우는가?
데이터 적용할 뷰 가져오기
fragment 의 onViewCreated 메소드는, view를 인자로 받는다!! 이를 활용하자
view.findViewById<>() 를 통해, 원하는 뷰를 불러온다
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val toolBarTitle = view.findViewById<TextView>(R.id.toolbar_home_title)
val toolBarIcon = view.findViewById<ImageView>(R.id.toolbar_home_icon)
불러온 뷰에 데이터 적용시키기
if(!homeData.isNullOrEmpty()){
val jsonObject = JSONObject(homeData)
val title = jsonObject.getJSONObject("title")
val text = title.getString("text")
val iconUrl = title.getString("icon_url")
toolBarTitle.text = text
GlideApp.with(this)
.load(iconUrl)
.into(toolBarIcon)
}