简体   繁体   中英

How to remove error “Unresolved reference text” in kotlin

I am trying to create a basic android project,but i am getting a constant error "Unresolved reference text".How to resolve it?

package com.example.shashank.simpson2

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.View
import com.example.shashank.simpson2.R.id.*
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.activity_main.view.*

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
}


 fun change(view: View)
     {

        val x=Simpson(nameText.text.toString(), Integer.parseInt(ageText.text.toString()), jobText.text.toString())
textView.text="Name "+x.name+"Age "+x.age+"Job "+x.job
  }

What you want to achieve here is to reference the view by its id in your kotlin code. You should check if you've added all the necessary plugins and implementations in your gradle script. This link thoroughly explains your problem's solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM