Advertisement
GigaSer

Untitled

Jun 9th, 2021
1,057
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.28 KB | None | 0 0
  1. package ru.gigaser.hypersmm
  2.  
  3. import android.os.Bundle
  4. import android.view.LayoutInflater
  5. import android.view.View
  6. import android.view.ViewGroup
  7. import android.widget.Button
  8. import android.widget.TextView
  9. import android.widget.Toast
  10. import androidx.core.os.bundleOf
  11. import androidx.fragment.app.Fragment
  12. import androidx.fragment.app.setFragmentResult
  13.  
  14. class LoginFragment : Fragment() {
  15.  
  16.     override fun onCreateView(
  17.         inflater: LayoutInflater, container: ViewGroup?,
  18.         savedInstanceState: Bundle?
  19.     ): View? {
  20.         return inflater.inflate(R.layout.fragment_login, container, false)
  21.     }
  22.  
  23.     override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
  24.         super.onViewCreated(view, savedInstanceState)
  25.  
  26.         val activity = requireActivity()
  27.         val button = activity.findViewById<Button>(R.id.accept)
  28.         Toast.makeText(requireContext(), lifecycle.currentState.toString(), Toast.LENGTH_SHORT).show()
  29.         button.setOnClickListener {
  30.             setFragmentResult("loginRequestResult", bundleOf(
  31.                 "login" to activity.findViewById<TextView>(R.id.login_input).text.toString(),
  32.                 "password" to activity.findViewById<TextView>(R.id.login_password_input).text.toString()
  33.             ))
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement