Repo for Programming MB code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
998 B

  1. package com.example.garagedoor
  2. import android.os.Bundle
  3. import androidx.fragment.app.Fragment
  4. import android.view.LayoutInflater
  5. import android.view.View
  6. import android.view.ViewGroup
  7. import android.widget.Button
  8. import androidx.navigation.fragment.findNavController
  9. /**
  10. * A simple [Fragment] subclass as the default destination in the navigation.
  11. */
  12. class FirstFragment : Fragment() {
  13. override fun onCreateView(
  14. inflater: LayoutInflater, container: ViewGroup?,
  15. savedInstanceState: Bundle?
  16. ): View? {
  17. // Inflate the layout for this fragment
  18. return inflater.inflate(R.layout.fragment_first, container, false)
  19. }
  20. override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
  21. super.onViewCreated(view, savedInstanceState)
  22. view.findViewById<Button>(R.id.button_first).setOnClickListener {
  23. findNavController().navigate(R.id.action_FirstFragment_to_SecondFragment)
  24. }
  25. }
  26. }