add recyclerview
This commit is contained in:
parent
a8ffa47f1a
commit
9e363fed73
@ -4,7 +4,7 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2024-10-25T14:57:29.908730700Z">
|
<DropdownSelection timestamp="2024-10-29T14:53:18.958676800Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="LocalEmulator" identifier="path=C:\Users\adm\.android\avd\Medium_Phone_API_35.avd" />
|
<DeviceId pluginId="LocalEmulator" identifier="path=C:\Users\adm\.android\avd\Medium_Phone_API_35.avd" />
|
||||||
|
@ -7,4 +7,11 @@
|
|||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
<option name="id" value="Android" />
|
<option name="id" value="Android" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="VisualizationToolProject">
|
||||||
|
<option name="state">
|
||||||
|
<ProjectState>
|
||||||
|
<option name="scale" value="0.19619808601885064" />
|
||||||
|
</ProjectState>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
</project>
|
</project>
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.example.autorization.ui.adapters
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.recyclerview.widget.RecyclerView.Adapter
|
||||||
|
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
||||||
|
import com.example.autorization.R
|
||||||
|
import com.example.autorization.ui.fragments.signup.User
|
||||||
|
|
||||||
|
class UserAdapter(private val users:List<User>): Adapter<UserAdapter.UserViewHolder>() {
|
||||||
|
inner class UserViewHolder(view: View):ViewHolder(view) {
|
||||||
|
val userNameTextView = view.findViewById<TextView>(R.id.UserNameTextView)
|
||||||
|
val userEmailTextView = view.findViewById<TextView>(R.id.UserEmailTextView)
|
||||||
|
val userPasswordTextView = view.findViewById<TextView>(R.id.UserPasswordTextView)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): UserViewHolder {
|
||||||
|
return UserViewHolder(LayoutInflater.from(parent.context)
|
||||||
|
.inflate(R.layout.user_item, parent, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount(): Int = users.size
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: UserViewHolder, position: Int) {
|
||||||
|
holder.userNameTextView.text = users[position].name
|
||||||
|
holder.userEmailTextView.text = users[position].email
|
||||||
|
holder.userPasswordTextView.text = users[position].password
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.example.autorization.ui.fragments
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.fragment.app.viewModels
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||||
|
import com.example.autorization.R
|
||||||
|
import com.example.autorization.ui.adapters.UserAdapter
|
||||||
|
import com.example.autorization.ui.fragments.signup.SignUpViewModel
|
||||||
|
import com.example.autorization.ui.fragments.signup.User
|
||||||
|
|
||||||
|
|
||||||
|
class UsersFragment : Fragment(R.layout.fragment_users) {
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
val recyclerView = view.findViewById<RecyclerView>(R.id.UserRecyclerView)
|
||||||
|
val users: List<User> = mutableListOf(
|
||||||
|
User(email = "test@mail.ru", name = "Alex", password = "123"),
|
||||||
|
User(email = "test@mail.ru", name = "Bob", password = "321"),
|
||||||
|
User(email = "test@mail.ru", name = "Alex", password = "123"),
|
||||||
|
User(email = "test@mail.ru", name = "Bob", password = "321"),
|
||||||
|
User(email = "test@mail.ru", name = "Alex", password = "123"),
|
||||||
|
User(email = "test@mail.ru", name = "Alex", password = "123"),
|
||||||
|
User(email = "test@mail.ru", name = "Bob", password = "321"),
|
||||||
|
User(email = "test@mail.ru", name = "Alex", password = "123"),
|
||||||
|
)
|
||||||
|
recyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||||
|
val userAdapter = UserAdapter(users)
|
||||||
|
recyclerView.adapter = userAdapter
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.fragment.app.FragmentContainerView
|
||||||
android:id="@+id/fragment_container_view"
|
android:id="@+id/fragment_container_view"
|
||||||
android:name="com.example.autorization.ui.fragments.SplashScreenFragment"
|
android:name="com.example.autorization.ui.fragments.UsersFragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"/>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
15
app/src/main/res/layout/fragment_users.xml
Normal file
15
app/src/main/res/layout/fragment_users.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout 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=".ui.fragments.UsersFragment">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/UserRecyclerView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:itemCount="10"
|
||||||
|
tools:listitem="@layout/user_item" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
32
app/src/main/res/layout/user_item.xml
Normal file
32
app/src/main/res/layout/user_item.xml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_margin="5dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
app:cardCornerRadius="20dp"
|
||||||
|
android:layout_height="100dp">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/UserEmailTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@tools:sample/lorem"/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/UserNameTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@tools:sample/lorem"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/UserPasswordTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@tools:sample/lorem" />
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.cardview.widget.CardView>
|
Loading…
Reference in New Issue
Block a user