【问题标题】:Use DrawerLayout and FlyOutContainer使用 DrawerLayout 和 FlyOutContainer
【发布时间】:2013-07-29 11:25:52
【问题描述】:

我有一个问题,我想在我的布局中放入抽屉布局和 FlyOutContainer,但在错误日志中显示错误:无法将 DrawerLayout 强制转换为 FlyOutContainer 我该如何解决这个问题。我需要抽屉布局才能进入 MainActivity。

希望你能帮助我,对不起我的英语不好。

【问题讨论】:

标签: android flyout drawerlayout


【解决方案1】:

该演示中的代码膨胀布局并将布局的根视图转换为 FlyOutContainer。如果您更改布局 xml 以使根现在是 DrawerLayout,那么该代码将不再正确运行,您可能会收到 ClassCastException。你应该这样做(在 onCreate() 中):

setContentView(R.layout.your_activity_layout);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout_id);
FlyOutContainer flyOutContainner = (FlyOutContainer) findViewById(R.id.fly_out_container_id);

当然,如果您实际上不需要对这些视图/布局的引用,您可以在setContentView(...) 之后停止

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多