IllegalStateException when replacing a Fragment

前端 未结 2 908
攒了一身酷
攒了一身酷 2020-11-28 04:34

It\'s small Android 2.2 test application using the Compatibility Package. This is the (wrong, of course) way I try to replace a Fragment when receiving a click. I\'m trying

2条回答
  •  情歌与酒
    2020-11-28 05:17

    there is another way, when you are developing apps for tablet with big screens you can inflate diferents layout ffor each screen orientations.you just have to create the two layouts and named them with portrait or landscape, in onCreate it simply inflate the xml according with the orientation.

    on the onClick event just identify the orientation with: getResources().getConfiguration().orientation

    and do your stuff

提交回复
热议问题