Ilovalar
Dasturning asosiy kodlari
MainActivity.kt klass fayli kodi:
package com.example.mygrammar
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.example.mygrammar.databinding.ActivityMainBinding
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.learnBtn.setOnClickListener {
val i = Intent(this, GrammarActivity::class.java)
startActivity(i)
}
binding.settingsBtn.setOnClickListener {
val i = Intent(this, SettingsActivity::class.java)
startActivity(i)
}
}
}
LoginActivity.kt klass fayli kodi:
package com.example.mygrammar
import android.content.Intent
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.example.mygrammar.databinding.ActivityLoginBinding
class LoginActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val binding = ActivityLoginBinding.inflate(layoutInflater)
setContentView(binding.root)
title = "Login"
binding.loginButton.setOnClickListener {
if (binding.loginInput.text.toString() == "Sardor" && binding.passwordInput.text.toString() == "12345") {
val i = Intent(this, MainActivity::class.java)
startActivity(i)
finish()
} else {
Toast.makeText(this, "Login: Sardor\nPassword: 12345", Toast.LENGTH_SHORT).show()
}
}
}
}
GrammarActivity.kt klass fayli kodi
bu oynada asosiy ishimiz bajariladi:
package com.example.mygrammar
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AlertDialog
import androidx.core.view.forEach
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.mygrammar.databinding.ActivityGrammarBinding
import com.example.mygrammar.databinding.ItemWaveLineBinding
import com.example.mygrammar.databinding.ItemWordBinding
import java.util.*
class GrammarActivity : AppCompatActivity() {
private var selectedWord: String? = null
private var selectedView: ItemWordBinding? = null
private lateinit var binding: ActivityGrammarBinding
private var texts = listOf()
private var index = -1
private var trues = mutableListOf()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityGrammarBinding.inflate(layoutInflater)
setContentView(binding.root)
texts = listOf("Men maktabga boraman", "Men maktabda o'qiyman")
setData(texts[++index])
binding.oneLineView.setOnClickListener {
if (selectedWord != null && selectedView != null) {
trues[binding.chipGroup.indexOfChild(selectedView?.root)] =
getWordType(selectedWord) == WordLineType.ONE_LINE
drawLine(selectedView, WordLineType.ONE_LINE)
}
|