No view found for id 0x7f090005

后端 未结 2 1068
太阳男子
太阳男子 2021-01-23 23:39

I\'m starting to build a simple Android app so when I press my video button it calls a fragment which contains the video player, but I\'m always getting: No view found for id 0x

2条回答
  •  北海茫月
    2021-01-24 00:20

    On ft.add() the int parameter refers to the container to which you want to add the Fragment; you are trying to add the Fragment to the Fragment's own layout (Android doesn't find the View because it is not inflated yet, if it did it will throw and Exception in this case; you cannot add a Fragment to its own layout). You want to replace R.id.fragmentVideo with R.id.activityStart to add the Fragment to the current TableLayout that is part of the already inflated main_activity layout

提交回复
热议问题