簡體   English   中英

Eclipse Android項目錯誤提醒

[英]eclipse android project error remind

我從googlecode下載了一個開源android項目。 它的名字叫OSMAND 通過將java compile version to 1.6設置java compile version to 1.6並將android version to 4.0 "net.osmand.plus.activities.MainMenuActivity"項目只有Eclipse IDE警告的三個錯誤:

錯誤的兩個在類AccessibilityDelegat

我要求osmand谷歌群體。 我不知道為什么因為每周或其他原因而無法回答我的問題。 所以我在這里問。

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());
    }

}

它提醒我:

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.

此錯誤出現在句子“最終AccessibilityDelegate委托= new AccessibilityDelegate(hierarchy.getContext());”中,我在這里進行了分隔(以方便通知)

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);"

但我在此類中看到,有構造函數和attach方法定義。 我不知道問題出在哪里以及如何解決

似乎您正在被編譯器使用View.AccessibilityDelegate。 嘗試改用標准名稱,如下所示:

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

它應該與此一起工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM