Search code examples
androidxmlkotlinlayout

Can't access the textView ID


I'm trying to access the textView from layout xml file. I'm using textView.text method but it's not working. I'm trying to change the text with subtraction calculation result but I can not access textView ID. You can see the problem in attached SS.First , Second , Third


Solution

  • Please check your code.

    Example

    val mResultTextView = findViewById<EditText>(R.id.result)   
    val mAnswer = mResultTextView .text  
    

    You can try ViewBinding - reduse error's, it remove findViewId method and boilerplate code.