简体   繁体   English

Eclipse Android项目错误提醒

[英]eclipse android project error remind

I download an opensource android project from googlecode. 我从googlecode下载了一个开源android项目。 It's name is OSMAND . 它的名字叫OSMAND by setting the java compile version to 1.6 and android version to 4.0 . 通过将java compile version to 1.6设置java compile version to 1.6并将android version to 4.0 the project of "net.osmand.plus.activities.MainMenuActivity" have only three errors alerted by eclipse IDE: "net.osmand.plus.activities.MainMenuActivity"项目只有Eclipse IDE警告的三个错误:

The two of the error is in class AccessibilityDelegat , 错误的两个在类AccessibilityDelegat

I have asked in osmand google groups. 我要求osmand谷歌群体。 I don not know why my question is not answered because weeked or other reasons. 我不知道为什么因为每周或其他原因而无法回答我的问题。 So I ask here. 所以我在这里问。

package net.osmand.access;

import net.osmand.access.AccessibleLayout;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.FrameLayout;

// This class serves as a delegate of accessibility service
// providing a sort of touch exploration capability
// for a View hierarchy. It means that elements will be spoken
// on touch. Thus, you can slide your finger across the screen
// and hear available controls and items.
// Lift finger up on a control to make click.
//
// This class can not be instantiated directly.
// Use static method takeCareOf() to get it's functionality
// for respective objects.
//
public class AccessibilityDelegate extends AccessibleLayout {

    private AccessibilityDelegate(Context context) {
        super(context);
    }

    // Attach itself to a target View hierarchy to intercept touch events
    // and provide on-touch accessibility feedback.
    // Target View must be an instance of FrameLayout
    // or have a parent which is an instance of ViewGroup.
    private void attach(View target) {
        ViewGroup parent;
        if (target instanceof FrameLayout) {
            parent = (ViewGroup)target;
            while (parent.getChildCount() > 0) {
                View child = parent.getChildAt(0);
                parent.removeViewAt(0);
                addView(child);
            }
            parent.addView(this, new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        } else if (target.getParent() instanceof ViewGroup) {
            parent = (ViewGroup)target.getParent();
            int position = parent.indexOfChild(target);
            ViewGroup.LayoutParams params = target.getLayoutParams();
            parent.removeViewAt(position);
            addView(target, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            parent.addView(this, position, params);
        }
    }


    // Provide touch exploration capability for individual View
    // or whole View hierarchy. The hierarchy root specified
    // as an argument must either be an instance of FrameLayout
    // or have a parent that is an instance of ViewGroup.
    public static void takeCareOf(View hierarchy) {
  final AccessibilityDelegate delegate = new AccessibilityDelegate(hierarchy.getContext()); 
        delegate.attach(hierarchy);
    }

    // Provide touch exploration capability for given window.
    public static void takeCareOf(Window window) {
        takeCareOf(window.getDecorView());
    }

    // Provide touch exploration capability for an activity View content.
    // Use after setContentView().
    public static void takeCareOf(Activity activity) {
        takeCareOf(activity.getWindow());
    }

    // Provide touch exploration capability for a dialog View content.
    // Use after setContentView().
    public static void takeCareOf(Dialog dialog) {
        takeCareOf(dialog.getWindow());
    }

}

It remind me that: 它提醒我:

The constructor View.AccessibilityDelegate(Context) is undefined   
Resource: AccessibilityDelegate.java   
Path: /net.osmand.plus.activities.MainMenuActivity/src/net/osmand/access    
Location:line 60    Type:Java Problem.

this error appear in sentence " final AccessibilityDelegate delegate = new AccessibilityDelegate(hierarchy.getContext()); ", I have seperated in here(for notice convenient) 此错误出现在句子“最终AccessibilityDelegate委托= new AccessibilityDelegate(hierarchy.getContext());”中,我在这里进行了分隔(以方便通知)

and

The method attach(View) is undefined for the type View.AccessibilityDelegate    

Resource:AccessibilityDelegate.java
Path:/net.osmand.plus.activities.MainMenuActivity/src/net/osmand/access    
Location: line 61    Type:Java Problem
this error appear in the next of my seperated line, in sentence       "delegate.attach(hierarchy);"

But I see in this class , there have the constructor function and the attach method defination. 但我在此类中看到,有构造函数和attach方法定义。 I don not know the problem come from and how to correct it 我不知道问题出在哪里以及如何解决

It seems as if you are being made to use the View.AccessibilityDelegate by the compiler. 似乎您正在被编译器使用View.AccessibilityDelegate。 Try using a fully qualified name instead, like this: 尝试改用标准名称,如下所示:

final net.osmand.access.AccessibilityDelegate delegate = new net.osmand.access.AccessibilityDelegate(hierarchy.getContext());

It should work with this. 它应该与此一起工作。

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

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