我试图在运行时使用Anko进行布局。它说错误,但我不知道错误是什么意思。我要做的只是像Anko的工作方式一样放置 UI ,但我不知道会发生什么。
这是我的代码:
class LastActivity : Fragment(), MainView {
private var teams: MutableList<Team> = mutableListOf()
private lateinit var presenter: LastActivity.MainPresenter
private lateinit var adapter: MainAdapter
private lateinit var listTeam: RecyclerView
private lateinit var progressBar: ProgressBar
private lateinit var swipeRefresh: SwipeRefreshLayout
private lateinit var leagueName: String
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return UI {
linearLayout {
lparams(width = matchParent, height = wrapContent)
orientation = LinearLayout.VERTICAL
topPadding = dip(16)
leftPadding = dip(16)
rightPadding = dip(16)
swipeRefresh = swipeRefreshLayout {
setColorSchemeResources(colorAccent,
android.R.color.holo_green_light,
android.R.color.holo_orange_light,
android.R.color.holo_red_light)
relativeLayout {
lparams(width = matchParent, height = wrapContent)
listTeam = recyclerView {
lparams(width = matchParent, height = wrapContent)
layoutManager = LinearLayoutManager(ctx)
}
progressBar = progressBar {
}.lparams {
centerHorizontally()
}
}
}
}
}.view()
}
}
这是错误信息
java.lang.IllegalStateException: View is already set: org.jetbrains.anko._LinearLayout{af3f3df V.E...... ......I. 0,0-0,0}
有人知道实际发生了什么,我该如何解决?
请帮助