findFragmentById always returns null

前端 未结 9 598
时光说笑
时光说笑 2020-12-01 17:31

I\'m defining an ID for my fragment in the xml layout:




        
9条回答
  •  -上瘾入骨i
    2020-12-01 18:09

    R.id.test_fragment is your LinearLayout ID not your Fragment.

    You can define and id on a fragment when it is inflated from an xml like in this sample http://developer.android.com/guide/topics/fundamentals/fragments.html#Adding

提交回复
热议问题