Android Sudoku Tutorial in Kotlin #3 - Game Backend with ViewModel/LiveData

Поділитися
Вставка
  • Опубліковано 3 жов 2024

КОМЕНТАРІ • 35

  • @iosifabramov254
    @iosifabramov254 3 роки тому +7

    Hello Patrick! I need help. in 'PlaySudokuActivity' file you have: viewModel = ViewModelProviders.of(arguments). Now I have viewModel = ViewModelProvider.of(arguments), and '.of' is not recognizable because in my case - import androidx.lifecycle.ViewModelProvider instead of yours android.arch.lifecycle.ViewModelProviders. I don't how to fix it.

  • @abdelmonemkhedr2202
    @abdelmonemkhedr2202 3 роки тому

    Your explanations are on point.Thank you for the great tutorial!

  • @HanselGretelBooktalk
    @HanselGretelBooktalk 3 роки тому +2

    I had a similar issue that some people below were having. The project wouldn't recognize the import kotlinx... so it wouldn't get the reference to sudokuBoardView.updateSelectedCellUI or registerListener. I had to check the build.gradle(:app) file and under "plugins", I added : id 'kotlin-android-extensions' in order to fix it.

    • @seonghwahong469
      @seonghwahong469 3 роки тому

      @@onlydecafThank you. The "View binding" works for registerListener. But in the case of updateSelectedCellUI, it doesn't work. The word 'binding' in the
      private fun updateSelectedCellUI(cell:Pair?) = cell?.let {
      binding.sudokuBoardView.updateSelectedCellUI(cell.first, cell.second)
      is red.

    • @seonghwahong469
      @seonghwahong469 3 роки тому

      @@onlydecaf Thank you very much!

  • @simsim819
    @simsim819 2 роки тому +1

    Hi Patrick, at 9:37, you were calling sudokuBoardView but I could not find where it was defined and initialized. My compiler won't let me go further. It is a great tutorial!

    • @PrasannaSrinivasanV
      @PrasannaSrinivasanV 2 роки тому

      This is answered in an earlier comment down below: ua-cam.com/video/0_gtvFtZjQ8/v-deo.html&lc=UgzpjqzoROoTih-Epqx4AaABAg.8sMLps7mJni8sR9wNFiGvR&ab_channel=PatrickFeltes.

  • @eeriksp
    @eeriksp 3 роки тому +3

    In 2021 you need to add `apply plugin: 'kotlin-android-extensions'` to your build.gradle, otherwise finding the view from the XML does not work and you will not get past 9:40 in the video.

    • @ralsoc9797
      @ralsoc9797 3 роки тому +1

      in which part of build gradle should be added?

  • @ejkeebler
    @ejkeebler 5 років тому +2

    unfortunately i'm doing something wrong, I cannot reference the three functions from the SudokuBoardView.kt, i even tried using the ones from the github, and still invalid references:
    SudokuBoardView.updateCells(cells) just will not resolve

    • @PatrickFeltes
      @PatrickFeltes  5 років тому +3

      Make sure you have this imported: import kotlinx.android.synthetic.main.activity_play_sudoku.*
      Kotlin adds support for these kotlinx extensions which allow us to grab UI components without having to do findViewById.
      So it should be sudokuBoardView.updateCells(cells) if "sudokuBoardView" is the id of your SudokuBoardView in the activity_play_sudoku.xml layout file.
      Let me know if this helps!

    • @ejkeebler
      @ejkeebler 5 років тому

      @@PatrickFeltes I was totally missing the connection, that I should be looking for the id of the element rather than using the id of the class lol, wow.... thanks this helped

  • @Ghost039
    @Ghost039 4 роки тому +1

    Dude, these tutorials are amazing. I'm working through it in Java so there are always a few bits here and there I have to learn on my own. But you explain so much of this so well, that I barely struggle to figure out what it is I need to do differently in Java.

    • @MishLoumova
      @MishLoumova 4 роки тому

      Hi, I'm also working through it in Java and I'm struggling a bit at 9:40, I don't know how to access "sudokuBoardView". How did you solve it? Thanks :)

    • @PrasannaSrinivasanV
      @PrasannaSrinivasanV 2 роки тому

      @@MishLoumova See reply to an earlier comment thread here: ua-cam.com/video/0_gtvFtZjQ8/v-deo.html&lc=UgzpjqzoROoTih-Epqx4AaABAg.8sMLps7mJni8sR9wNFiGvR

  • @andipstha
    @andipstha 5 років тому

    How can i figure out [ Unresolved reference: sudokuBoardView
    PlaySudokuActivites.kt
    code no: 20 sudokuBoardView.registerListener(this)
    code no: 29 sudokuBoardView.updateCells(cells)
    code no: 33 sudokuBoardView.updateSelectedCellUI(cell.first, cell.second)

    • @LegendTerror65
      @LegendTerror65 5 років тому

      private fun updateSelectedCellUI(cell: Pair?) = cell?.let {
      Looks.updateSelectedCellUI(cell.first,cell.second)

    • @LegendTerror65
      @LegendTerror65 5 років тому

      update this in ur board view
      fun updateSelectedCellUI(row: Int, col:Int){
      selectedRow = row
      selectedCol = col
      invalidate()
      }

  • @bytelaw1711
    @bytelaw1711 5 років тому

    Whats the program you use for programming kotlin

    • @PatrickFeltes
      @PatrickFeltes  5 років тому

      This is Android Studio, which has support for Kotlin and Android. If you want to program in just Kotlin and not Android, you should use IntelliJ.

  • @dawkins75
    @dawkins75 4 роки тому

    I'm stuck. I keep getting this error:
    Unresolved reference: updateSelectedCellUI
    I verified the I'm importing the SudokuBoardView in my MainActivity.kt, and I verified that in SudokuBoardView I put the function updateSelectedCellUI code. I double and triple checked the spelling and everything. In MainActivity, the SudokuBoardView.updateSelectedCellUI is in red, so it's not finding it, but I confirmed it's there. are there any settings I need to check?

    • @PatrickFeltes
      @PatrickFeltes  4 роки тому

      In MainActivity, are you calling `sudokuBoardView.updateSelectedCellUI` or `SudokuBoardView.updateSelectedCellUI`? It should be the first one since we are calling the function on our instance of SudokuBoardView, which is called `sudokuBoardView` with the lowercase 's'.

    • @dawkins75
      @dawkins75 4 роки тому

      @@PatrickFeltes Hi Patrick, thanks for the response. I think I may have missed where we create the instance of SodukuBoardView. When I use lower case "s", then sudokuBoardView appears in red. So i must have not created the instance correctly. Where are we creating it? I downloaded your version from GitHub, but I couldn't find the sudokuBoardView instantiation.
      FYI, I liked and subscribed. Great work.

    • @PatrickFeltes
      @PatrickFeltes  4 роки тому +1

      @@dawkins75 So the issue is that we create the sudokuBoardView in the xml file for the MainActivity. I am using the kotlinx extension functions which let us reference views by their ids (instead of using findViewById), so you need to match it with whatever your id is in the xml file. Also, make sure you have this import:
      `import kotlinx.android.synthetic.main.activity_play_sudoku.*`
      Thanks for the like and subscribe! Hope this helps! If not, let me know.

    • @dawkins75
      @dawkins75 4 роки тому

      @@PatrickFeltes Thanks Patrick, that did it. Turns out I misspelled it in the XML file. Seems to be ok now.
      Keep up the good work.

  • @cid
    @cid 4 роки тому

    Thank you for this tutorial. This improved my Kotlin abilities

    • @brantleybode2578
      @brantleybode2578 3 роки тому

      i guess I'm quite randomly asking but does anybody know a good site to stream new movies online ?

    • @arielkarsyn9710
      @arielkarsyn9710 3 роки тому

      @Brantley Bode Lately I have been using FlixZone. You can find it by googling :)

    • @kaisonsamson3480
      @kaisonsamson3480 3 роки тому

      @Ariel Karsyn yea, I've been using FlixZone for years myself :)

    • @brantleybode2578
      @brantleybode2578 3 роки тому

      @Ariel Karsyn Thanks, I signed up and it seems like they got a lot of movies there :D I appreciate it !!

    • @arielkarsyn9710
      @arielkarsyn9710 3 роки тому

      @Brantley Bode glad I could help :)

  • @bytelaw1711
    @bytelaw1711 5 років тому

    when is the next part?? do you have some sort of schedule or something? if yes then what is it..?

    • @PatrickFeltes
      @PatrickFeltes  5 років тому

      Hey, I’m planning to release a new video every Sunday morning from now on. I just released a whole bunch since I was on winter break, but from now on it should be at least once a week on Sunday mornings!

    • @bytelaw1711
      @bytelaw1711 5 років тому

      @@PatrickFeltes k thx

    • @PatrickFeltes
      @PatrickFeltes  5 років тому

      Sorry for the delay, but the next video is now up!