Skip to content

Instantly share code, notes, and snippets.

@BKinya
Created December 12, 2019 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BKinya/4707cd78424c709ed8a9d2f421fb0d04 to your computer and use it in GitHub Desktop.
Save BKinya/4707cd78424c709ed8a9d2f421fb0d04 to your computer and use it in GitHub Desktop.
LoginFragment
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