Activity 中的 findViewById (int) 无法应用于 (int, android.support.v7.widget.Toolbar
findViewById (int) in Activity cannot be applied to (int, android.support.v7.widget.Toolbar
所以一直在关注Slidnerd tutorial on the Navigation Drawer。当我尝试创建 ActionBarDrawerToggle 实例以指定 Activity
、DrawerLayout
和 Toolbar
时,问题就出现了。
(NavigationDrawerFragment)getSupportFragmentManager().findFragmentById(R.id.fragment_nav_drawer);
drawerFragment.setUp((DrawerLayout) findViewById (R.id.drawer_layout, toolbar);
我在 (R.id.drawer_layout,工具栏) 下遇到错误。错误说:" findViewById (int) in Activity cannot be applied to (int, android.support.v7.widget.Toolbar".
我尝试了一个建议的解决方案,即导入 android.support.v4.app.Fragment 但即使尝试了这个问题仍然存在,我什至尝试了反之亦然。如果需要,我也愿意 post 我的相关代码。
有谁知道如何解决这个问题?
感谢所有帮助。谢谢,祝你有美好的一天!
这个错误是因为findViewById
只接受一个int,而不是一个int和一个Toolbar
。应该这样使用:
drawerFragment.setup((DrawerLayout)findViewById(R.id.drawer_layout), toolbar);
只要用这个替换你的行,错误就消失了....
drawerFragment.setUp((DrawerLayout)findViewById(R.id.drawer_layout), toolbar);
所以一直在关注Slidnerd tutorial on the Navigation Drawer。当我尝试创建 ActionBarDrawerToggle 实例以指定 Activity
、DrawerLayout
和 Toolbar
时,问题就出现了。
(NavigationDrawerFragment)getSupportFragmentManager().findFragmentById(R.id.fragment_nav_drawer);
drawerFragment.setUp((DrawerLayout) findViewById (R.id.drawer_layout, toolbar);
我在 (R.id.drawer_layout,工具栏) 下遇到错误。错误说:" findViewById (int) in Activity cannot be applied to (int, android.support.v7.widget.Toolbar".
我尝试了一个建议的解决方案,即导入 android.support.v4.app.Fragment 但即使尝试了这个问题仍然存在,我什至尝试了反之亦然。如果需要,我也愿意 post 我的相关代码。
有谁知道如何解决这个问题?
感谢所有帮助。谢谢,祝你有美好的一天!
这个错误是因为findViewById
只接受一个int,而不是一个int和一个Toolbar
。应该这样使用:
drawerFragment.setup((DrawerLayout)findViewById(R.id.drawer_layout), toolbar);
只要用这个替换你的行,错误就消失了....
drawerFragment.setUp((DrawerLayout)findViewById(R.id.drawer_layout), toolbar);