Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit 196cb3fd authored by 62160052's avatar 62160052
Browse files

Use LiveData with data binding

parent de9d6151
No related branches found
No related tags found
No related merge requests found
...@@ -47,7 +47,7 @@ android { ...@@ -47,7 +47,7 @@ android {
jvmTarget = '1.8' jvmTarget = '1.8'
} }
buildFeatures { buildFeatures {
viewBinding true dataBinding = true
} }
} }
......
...@@ -21,6 +21,7 @@ import android.util.Log ...@@ -21,6 +21,7 @@ import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import com.example.android.unscramble.R import com.example.android.unscramble.R
import com.example.android.unscramble.databinding.GameFragmentBinding import com.example.android.unscramble.databinding.GameFragmentBinding
...@@ -48,7 +49,7 @@ class GameFragment : Fragment() { ...@@ -48,7 +49,7 @@ class GameFragment : Fragment() {
inflater: LayoutInflater, container: ViewGroup?, inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View { ): View {
binding = GameFragmentBinding.inflate(inflater, container, false) binding = DataBindingUtil.inflate(inflater, R.layout.game_fragment, container, false)
Log.d("GameFragment", "Word: ${viewModel.currentScrambledWord} " + Log.d("GameFragment", "Word: ${viewModel.currentScrambledWord} " +
"Score: ${viewModel.score} WordCount: ${viewModel.currentWordCount}") "Score: ${viewModel.score} WordCount: ${viewModel.currentWordCount}")
return binding.root return binding.root
......
...@@ -14,9 +14,15 @@ ...@@ -14,9 +14,15 @@
~ limitations under the License. ~ limitations under the License.
--> -->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools">
<data>
</data>
<ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
...@@ -118,3 +124,4 @@ ...@@ -118,3 +124,4 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>
</layout>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment