Добавить RecyclerView в SwipeRefreshLayout
Мне нужно добавить RecyclerView в SwipeRefresh программно так как постоянно приходится его пересоздавать, но он не добавляется
val mAdapter = PagedAdapterMovie()
recyclerView = RecyclerView(swipeRefreshLayout.context).apply {
val mLayoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT)
mLayoutParams.topMargin = 10
layoutParams = mLayoutParams
layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
adapter = mAdapter
}
Log.e("TAG","add Linear")
// linearLayout.addView(recyclerView)
Log.e("TAG","add swipe")
swipeRefreshLayout.addView(recyclerView)
Я проверял в LinearLayout,он добавляется без проблем, но в Swipe не хочет