首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >项目错误提醒

项目错误提醒
EN

Stack Overflow用户
提问于 2013-01-13 15:24:49
回答 1查看 412关注 0票数 1

我从googlecode下载了一个开源android项目。它叫OSMAND。通过设置java compile version to 1.6android version to 4.0"net.osmand.plus.activities.MainMenuActivity"项目只有三个错误被eclipse警告:

两个错误在AccessibilityDelegat类中,

我曾在奥斯曼德谷歌()咨询过。我不知道为什么我的问题没有答案,因为除草或其他原因。所以我在这里问。

代码语言:javascript
复制
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());

代码语言:javascript
复制
        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());
    }

}

它提醒我:

代码语言:javascript
复制
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委托=新AccessibilityDelegate”中,我在这里已经分开了(为了方便起见)

代码语言:javascript
复制
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);"

但是我看到在这个类中,有构造函数和附加方法定义。我不知道这个问题是怎么解决的,也不知道如何纠正。

EN

回答 1

Stack Overflow用户

发布于 2013-01-13 16:34:52

似乎是编译器让您使用View.AccessibilityDelegate。尝试使用完全限定的名称,如下所示:

代码语言:javascript
复制
final net.osmand.access.AccessibilityDelegate delegate = new net.osmand.access.AccessibilityDelegate(hierarchy.getContext());

它应该能解决这个问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14304876

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档