Шаблон для разработки
This commit is contained in:
parent
3e6fe310e0
commit
a0c512c900
@ -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.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import ru.myitschool.work.databinding.ItemBookBinding
|
||||
|
||||
class BookAdapter(private val bookList: List<Book>) : RecyclerView.Adapter<BookAdapter.BookViewHolder>() {
|
||||
|
||||
//TODO: Реализовать класс BookViewHolder, используя binding
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BookViewHolder {
|
||||
val inflater = LayoutInflater.from(parent.context)
|
||||
val binding = ItemBookBinding.inflate(inflater, parent, false)
|
||||
return BookViewHolder(binding)
|
||||
}
|
||||
|
||||
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: Создать и заполнить RecyclerView
|
||||
}
|
||||
}
|
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>
|
22
app/src/main/res/layout/item_book.xml
Normal file
22
app/src/main/res/layout/item_book.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?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"
|
||||
android:id="@+id/infoContainer">
|
||||
|
||||
<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>
|
Loading…
x
Reference in New Issue
Block a user