Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't link "tvTodoTitle.text" (and) "cbDone.isChecked"... (No import option in pop-up, see screenshot) #6

Open
JustinKirton opened this issue Jan 18, 2023 · 5 comments

Comments

@JustinKirton
Copy link

JustinKirton commented Jan 18, 2023

Very clear and easy to follow tutorial by the way.

Needless to say, I'm new to this and can assume that my version could have changed some of the parameters from the version you're using.

All ok till 47:40 (approx.)...

I "alt+ enter", as suggested and got no 'import' option from the pop-up... (It was all going so well)

I looked back through the other files to see if there were any mistakes.

I see that the file "item_todo.xml" contains the title so I assume it is referencing this particular file.

2023-01-18tvTodotitle

@awhic
Copy link

awhic commented Jan 19, 2023

Need to use view binding instead: https://developer.android.com/topic/libraries/view-binding

Add this to build,gradle on module level:

android {
...
buildFeatures {
viewBinding = true
}
}

So it would be something like private lateinit var binding: ItemTodoBinding
binding.tvTodoTitle.text, etc...

@MarkNzioka
Copy link

Did you get the solution to this problem? @JustinKirton

@muiz2353673
Copy link

I am too getting the same error. Anybody got any solution please do ping me.

@BitMavrick
Copy link

BitMavrick commented Mar 28, 2023

I find out the problem that is we have to implement

apply plugin: 'kotlin-android-extensions'

to app/build.gradle file. But it's not supported right now

You can watch this tutorials to solve this issue

https://www.youtube.com/watch?v=z0F2QTAKsWU

@ArifKuru
Copy link

apply plugin: 'kotlin-android-extensions'
it is not supported any longer , you need to initialize itemViews

class TodoViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
                val tvTodoTitle: TextView = itemView.findViewById(R.id.tvTodoTitle)
                val cbDone: CheckBox = itemView.findViewById(R.id.cbDone)            }

in MainActivity.kt you can initialize them like this:

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

     val rvTodoItems: RecyclerView = findViewById(R.id.rvTodoItems)
     val btnAddTodo: Button = findViewById(R.id.btnAddTodo)
     val etTodoTitle: EditText = findViewById(R.id.etTodoTitle)
     val btnDeleteDone: Button = findViewById(R.id.btnDeleteDone)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants