简体   繁体   English

如何在kotlin中删除错误“未解析的参考文本”

[英]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? 我正在尝试创建一个基本的android项目,但我得到一个常量错误“未解析的参考文本”。如何解决它?

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. 你想在这里实现的是通过你的kotlin代码中的id来引用视图。 You should check if you've added all the necessary plugins and implementations in your gradle script. 您应该检查是否已在gradle脚本中添加了所有必需的插件和实现。 This link thoroughly explains your problem's solution. 链接彻底解释了您的问题的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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