Reputation: 1
I have an activity named BaseActivity and I want to access a textview from another xml called dialog_progress in the BaseActivity. How do I do it
wrote the following code
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()
}
it gives me an error saying unresolved reference for tvTextView
Upvotes: 0
Views: 72
Reputation: 3100
give progressDialog
reference to findViewById
try below code
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()
}
Upvotes: 1