如何在android / eclipse上设置Jfeinstein10滑动菜单

时间:2012-12-21 13:58:13

标签: android eclipse menu compiler-errors sliding

我正试图在日食中设置JFeinstein10的sliding menu

我尝试了什么:

  1. file > import > from existing android.. > select the library of sliding menu
  2. file > import > from ex.. > select the example of sliding me
  3. file > import > from ex.. > select actionbarsherlock library
  4. mark slidingmenu lib and actionbarlib as library
  5. add the library's to example of sldingmenu
  6. cleanup all
  7. 然后我得到各种错误(比如:jar不匹配,..无法解析为类型,类型的方法..必须覆盖超类方法)我google了他们并使用清理和快速修复选项。但我不行。

    我希望你们中的一个人知道一个好的教程,或者也许能够写一个或知道该怎么做。

    我是Android开发的新手,以前的所有应用都是用webview制作的。

    我也试过https://github.com/johnkil/SideNavigation(也没用,如果有人知道如何设置这个,很棒!)和grimbo滑动菜单(它有效,但它不是我想要的)

    错误仅在slidingmapactivity中显示在库中(如下所示),在actibarsherlock库中有许多错误文件(几乎在src文件夹中的任何文件中)

    code in lib: slidingmapactivity:
    package com.slidingmenu.lib.app;
    
    import android.os.Bundle;
    import android.view.KeyEvent;
    import android.view.View;
    import android.view.ViewGroup.LayoutParams;
    
    import com.slidingmenu.lib.SlidingMenu;
    
    public abstract class SlidingMapActivity extends MapActivity implements         SlidingActivityBase {
    
    private SlidingActivityHelper mHelper;
    
    /* (non-Javadoc)
     * @see com.google.android.maps.MapActivity#onCreate(android.os.Bundle)
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mHelper = new SlidingActivityHelper(this);
        mHelper.onCreate(savedInstanceState);
    }
    
    /* (non-Javadoc)
     * @see android.app.Activity#onPostCreate(android.os.Bundle)
     */
    @Override
    public void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        mHelper.onPostCreate(savedInstanceState);
    }
    
    /* (non-Javadoc)
     * @see android.app.Activity#findViewById(int)
     */
    @Override
    public View findViewById(int id) {
        View v = super.findViewById(id);
        if (v != null)
            return v;
        return mHelper.findViewById(id);
    }
    
    /* (non-Javadoc)
     * @see android.app.Activity#onSaveInstanceState(android.os.Bundle)
     */
    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        mHelper.onSaveInstanceState(outState);
    }
    
    /* (non-Javadoc)
     * @see android.app.Activity#setContentView(int)
     */
    @Override
    public void setContentView(int id) {
        setContentView(getLayoutInflater().inflate(id, null));
    }
    
    /* (non-Javadoc)
     * @see android.app.Activity#setContentView(android.view.View)
     */
    @Override
    public void setContentView(View v) {
        setContentView(v, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    }
    
    /* (non-Javadoc)
     * @see android.app.Activity#setContentView(android.view.View, android.view.ViewGroup.LayoutParams)
     */
    @Override
    public void setContentView(View v, LayoutParams params) {
        super.setContentView(v, params);
        mHelper.registerAboveContentView(v, params);
    }
    
    /* (non-Javadoc)
     * @see com.slidingmenu.lib.app.SlidingActivityBase#setBehindContentView(int)
     */
    @Override
    public void setBehindContentView(int id) {
        setBehindContentView(getLayoutInflater().inflate(id, null));
    }
    
    /* (non-Javadoc)
     * @see com.slidingmenu.lib.app.SlidingActivityBase#setBehindContentView(android.view.View)
     */
    @Override
    public void setBehindContentView(View v) {
        setBehindContentView(v, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    }
    
    /* (non-Javadoc)
     * @see com.slidingmenu.lib.app.SlidingActivityBase#setBehindContentView(android.view.View, android.view.ViewGroup.LayoutParams)
     */
    @Override
    public void setBehindContentView(View v, LayoutParams params) {
        mHelper.setBehindContentView(v, params);
    }
    
    /* (non-Javadoc)
     * @see com.slidingmenu.lib.app.SlidingActivityBase#getSlidingMenu()
     */
    @Override
    public SlidingMenu getSlidingMenu() {
        return mHelper.getSlidingMenu();
    }
    
    /* (non-Javadoc)
     * @see com.slidingmenu.lib.app.SlidingActivityBase#toggle()
     */
    @Override
    public void toggle() {
        mHelper.toggle();
    }
    
    /* (non-Javadoc)
     * @see com.slidingmenu.lib.app.SlidingActivityBase#showAbove()
     */
    @Override
    public void showContent() {
        mHelper.showContent();
    }
    
    /* (non-Javadoc)
     * @see com.slidingmenu.lib.app.SlidingActivityBase#showBehind()
     */
    @Override
    public void showMenu() {
        mHelper.showMenu();
    }
    
    /* (non-Javadoc)
     * @see com.slidingmenu.lib.app.SlidingActivityBase#showSecondaryMenu()
     */
    @Override
    public void showSecondaryMenu() {
        mHelper.showSecondaryMenu();
    }
    
    /* (non-Javadoc)
     * @see com.slidingmenu.lib.app.SlidingActivityBase#setSlidingActionBarEnabled(boolean)
     */
    @Override
    public void setSlidingActionBarEnabled(boolean b) {
        mHelper.setSlidingActionBarEnabled(b);
    }
    
    /* (non-Javadoc)
     * @see android.app.Activity#onKeyUp(int, android.view.KeyEvent)
     */
    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        boolean b = mHelper.onKeyUp(keyCode, event);
        if (b) return b;
        return super.onKeyUp(keyCode, event);
    }
    

    }

2 个答案:

答案 0 :(得分:4)

我们一次只能解决这些问题......

  • JAR Mismatch - 我认为这是支持库。将SlidingMenu libs文件夹中的JAR替换为您自己的libs文件夹中的副本。

  • Cannot be resolved to a type表示您尚未点击项目属性并将SlidingMenu添加到库框中。如果失败,请按活动文件中的Cmd-Shift-O来修复导入。这也将解决我认为的@Override问题。

请告诉我您的情况,我会根据需要提供进一步的帮助。

答案 1 :(得分:0)

你需要在SLIDINGMENULIBRARY的libs目录以及PROJECT的libs文件夹中拥有相同的android-support-v4 JAR。

事实上去你的SDK文件夹转到sdk \ extras \ android \ support \ v4 \ android-support-v4.jar 复制这个jar并将其粘贴到两个目录中。