Skip to content

Instantly share code, notes, and snippets.

@bherbst
Last active July 21, 2017 14:21
Show Gist options
  • Save bherbst/f114b37cfdf3680e34612c72d6555f8d to your computer and use it in GitHub Desktop.
Save bherbst/f114b37cfdf3680e34612c72d6555f8d to your computer and use it in GitHub Desktop.
Android View Nullability
class SampleFragment : Fragment() {
private var textView: TextView? = null
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_main2, container, false)
}
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
textView = view?.findViewById<TextView>(R.id.textView)
Log.d("kotlinx", "onViewCreated textView ID: " + textView!!.id)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment