Created
December 12, 2019 20:33
-
-
Save BKinya/4707cd78424c709ed8a9d2f421fb0d04 to your computer and use it in GitHub Desktop.
LoginFragment
This file contains 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
class LoginFragment : Fragment() { | |
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, | |
savedInstanceState: Bundle?): View? { | |
// Inflate the layout for this fragment | |
val rootView = inflater.inflate(R.layout.fragment_login, container, false) | |
val usernameEditTxtview = rootView.findViewById<EditText>(R.id.username_edittxt) | |
val loginBtn = rootView.findViewById<Button>(R.id.login_btn) | |
//implement button setOnclickListener callback | |
loginBtn.setOnClickListener { | |
//check if the user has supplied their name | |
//then navigate to the main screen | |
val name = usernameEditTxtview.text.toString() | |
if (name.isNotEmpty()){ | |
findNavController().navigate(R.id.action_loginFragment_to_mainFragment) | |
} | |
} | |
return rootView; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment