Fragment: Relativelayout Visibility Not Changeable In Oncreateview
(Im using Kotlin) So here is my OnCreateView in the Fragment. override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
Solution 1:
Other than the ID seemingly not being right, as mentioned in a comment above...
Since at this stage your View
is not set for your Fragment
yet (you haven't returned it to the framework), you can't call findViewById
on the Fragment
itself, but you can make a findViewById
call on the newly inflated View
instead:
val view: View = inflater!!.inflate(R.layout.fragment_bots, container, false)
val bd2 = view.findViewById(R.id.BotDiv2)
bd2.visibility = View.VISIBLE
If you're using Kotlin Android Extensions, you can do the same with this syntax:
val view: View= inflater!!.inflate(R.layout.fragment_bots, container, false)
view.BotDiv2.visibility = View.VISIBLE
Post a Comment for "Fragment: Relativelayout Visibility Not Changeable In Oncreateview"