Шаблон практики
This commit is contained in:
parent
3e6fe310e0
commit
bf7de64522
@ -1,4 +1,5 @@
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.android")
|
||||
androidApplication
|
||||
}
|
||||
|
||||
@ -27,5 +28,9 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("androidx.appcompat:appcompat:1.7.0")
|
||||
implementation("com.google.android.material:material:1.12.0")
|
||||
implementation("androidx.activity:activity:1.9.1")
|
||||
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
|
||||
defaultLibrary()
|
||||
}
|
||||
|
@ -10,7 +10,14 @@
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Default"
|
||||
tools:targetApi="31" />
|
||||
android:theme="@style/Theme.Design.Light.NoActionBar"
|
||||
tools:targetApi="31">
|
||||
<activity android:name=".MainActivity" android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
3
app/src/main/java/ru/myitschool/work/Book.kt
Normal file
3
app/src/main/java/ru/myitschool/work/Book.kt
Normal file
@ -0,0 +1,3 @@
|
||||
package ru.myitschool.work
|
||||
|
||||
data class Book(val title: String, val author: String)
|
26
app/src/main/java/ru/myitschool/work/BookAdapter.kt
Normal file
26
app/src/main/java/ru/myitschool/work/BookAdapter.kt
Normal file
@ -0,0 +1,26 @@
|
||||
package ru.myitschool.work
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
class BookAdapter(private val bookList: List<Book>) : RecyclerView.Adapter<BookAdapter.BookViewHolder>() {
|
||||
|
||||
class BookViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
val titleTextView: TextView = itemView.findViewById(R.id.bookTitle)
|
||||
val authorTextView: TextView = itemView.findViewById(R.id.bookAuthor)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BookViewHolder {
|
||||
val itemView = LayoutInflater.from(parent.context).inflate(R.layout.item_book, parent, false)
|
||||
return BookViewHolder(itemView)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: BookViewHolder, position: Int) {
|
||||
//TODO: Заполнить
|
||||
}
|
||||
|
||||
override fun getItemCount() = bookList.size
|
||||
}
|
19
app/src/main/java/ru/myitschool/work/MainActivity.kt
Normal file
19
app/src/main/java/ru/myitschool/work/MainActivity.kt
Normal file
@ -0,0 +1,19 @@
|
||||
package ru.myitschool.work
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
enableEdgeToEdge()
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
//TODO: Заполнить
|
||||
}
|
||||
}
|
14
app/src/main/res/layout/activity_main.xml
Normal file
14
app/src/main/res/layout/activity_main.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="16dp" />
|
||||
|
||||
</RelativeLayout>
|
21
app/src/main/res/layout/item_book.xml
Normal file
21
app/src/main/res/layout/item_book.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bookTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bookAuthor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</LinearLayout>
|
@ -2,4 +2,5 @@
|
||||
plugins {
|
||||
androidApplication version Version.gradle apply false
|
||||
kotlinJvm version Version.Kotlin.language apply false
|
||||
id("org.jetbrains.kotlin.android") version "2.0.0" apply false
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user