简体   繁体   English

Android:实现SlidingMenu和ABS

[英]Android: Implementing SlidingMenu and ABS

I am trying to implement the SlidingMenu from https://github.com/jfeinstein10/SlidingMenu together with http://actionbarsherlock.com/ and I came across a problem that I could not fix myself that's why I turned to the issues page on SlidingMenu's GitHub. 我正在尝试从https://github.com/jfeinstein10/SlidingMenuhttp://actionbarsherlock.com/一起实现SlidingMenu,但遇到一个无法修复自己的问题,这就是为什么我转到问题页面SlidingMenu的GitHub。 But 2 days and I got no reply so I am gonna ask it here. 但是两天了,我没有回复,所以我要在这里问。

Basically on the example project provided by jfeinstein10, I copied the SampleListFragment.java file and I've named it MenuListFragment.java on my project. 基本上由jfeinstein10提供的示例项目,我复制了SampleListFragment.java文件,我已经把它命名为MenuListFragment.java在我的项目。 I've made a couple of changes but those should not be an issue. 我做了一些更改,但是这些不应该成为问题。

I also copied the menu.xml from the layout directory but changed its name attribute to the previous file including the package. 我还从布局目录中复制了menu.xml ,但将其name属性更改为包含软件包的先前文件。

Project builds properly and no errors are encountered. 项目构建正确,并且没有遇到错误。 Time to run the project. 是时候运行项目了。

Now on my project's main activity, when I call the setMenu(R.layout.menu); 现在在项目的主要活动中,当我调用setMenu(R.layout.menu); statement during runtime, it gives me an error which tells me something about ClassCastException (cannot cast com.dokgu.dota2stats.MenuListFragment to android.app.Fragment ). 语句在运行时,它给了我一个错误,它告诉我有关ClassCastException (无法将com.dokgu.dota2stats.MenuListFragment转换android.app.Fragment )。

I've tried a couple of things like change the MenuListFragment.java to extend the android.app.Fragment instead of ListFragment but it didn't solve the problem and more issues came up because of that. 我已经尝试了一些事情,例如更改MenuListFragment.java来扩展android.app.Fragment而不是ListFragment,但它没有解决问题,因此出现了更多问题。

So please, can anyone help me with this please? 所以,请问有人可以帮我吗? I really want to make this work. 我真的很想完成这项工作。

You can find the issue here as well: https://github.com/jfeinstein10/SlidingMenu/issues/546 您也可以在这里找到问题: https : //github.com/jfeinstein10/SlidingMenu/issues/546

Actionbarsherlork支持自android 2.x以来的较低杠杆版本,而slidemenu需要android 3.0+。也许您可以添加android-support-v4.jar,其中slidemenu项目中的某些片段和活动会扩展到该版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM