Skip to content

Instantly share code, notes, and snippets.

@Kshitij09
Last active July 5, 2020 20:17
Show Gist options
  • Save Kshitij09/1fc272ce9866f1ee20e485046a8e5366 to your computer and use it in GitHub Desktop.
Save Kshitij09/1fc272ce9866f1ee20e485046a8e5366 to your computer and use it in GitHub Desktop.
some snippets that could be useful in various scenarios
// Hide the keyboard on button click
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(view.windowToken, 0)
// hide the menu item if doesn't resolve
// getShareIntent() is supposed to return your intent object
if (null == getShareIntent().resolveActivity(activity!!.packageManager)) {
menu.findItem(R.id.share).setVisible(false)
}
@Kshitij09
Copy link
Author

Pro tip: Use <merge/> tag as the root layout when using Android's NavHostFragment to eliminate redundant layouts when including layouts. reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment