Created
June 25, 2020 09:34
-
-
Save prolongservices/72372538015fafdce7a320a74f11fd53 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.learnpainless.androidnavigation.fragments | |
| import android.os.Bundle | |
| import androidx.fragment.app.Fragment | |
| import android.view.LayoutInflater | |
| import android.view.View | |
| import android.view.ViewGroup | |
| import androidx.navigation.fragment.findNavController | |
| import com.learnpainless.androidnavigation.R | |
| import kotlinx.android.synthetic.main.fragment_second.* | |
| class SecondFragment : Fragment() { | |
| override fun onCreateView( | |
| inflater: LayoutInflater, container: ViewGroup?, | |
| savedInstanceState: Bundle? | |
| ): View? { | |
| // Inflate the layout for this fragment | |
| return inflater.inflate(R.layout.fragment_second, container, false) | |
| } | |
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
| super.onViewCreated(view, savedInstanceState) | |
| //button is id of button in xml file. | |
| button.setOnClickListener { | |
| val direction = SecondFragmentDirections.actionSecondFragmentToThirdFragment() | |
| findNavController().navigate(direction) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment