我有一个名为BaseActivity的活动,我想从另一个名为dialog_progress的xml中访问一个textview。我该怎么做呢
写了下面的代码
private var tvProgressText : Textview? = null
fun showProcessDialog(text: String){
mProgressDialog = Dialog(this)
mProgressDialog.setContentView(R.layout.dialog_progress)
tvProgressText = findViewById(R.id.tv_progress_bar)
mProgressDialog.tvProgressText = text
mProgressDialog.show()
}
它给了我一个错误说未解决的引用tvTextView
给progressDialog
引用findViewById
试试下面的代码
private var tvProgressText : Textview? = null
fun showProcessDialog(text: String){
mProgressDialog = Dialog(this)
mProgressDialog.setContentView(R.layout.dialog_progress)
tvProgressText = mProgressDialog.findViewById<TextView>(R.id.tv_progress_bar)
mProgressDialog.tvProgressText = text
mProgressDialog.show()
}