问题复制AbsoluteLayout - com.android.internal.R不能得到解决 [英] Problem copying AbsoluteLayout - com.android.internal.R cannot be resolved

查看:133
本文介绍了问题复制AbsoluteLayout - com.android.internal.R不能得到解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我来,唯一的解决办法是使用AbsoluteLayout(只是为了显示一些在特定的位置)。问题

I came to a problem that the only solutions is using a AbsoluteLayout (Just to show something at specific positions).

我试图复制AbsoluteLayout类,以避免它被取消了对未来版本和我的应用程序停止工作。

I'm trying to copy the AbsoluteLayout class to avoid it being removed on future releases and my app stop working.

我从这里复制:<一href="http://www.google.com/$c$csearch#cZwlSNS7aEw/frameworks/base/core/java/android/widget/AbsoluteLayout.java&exact_package=android&q=AbsoluteLayout&type=cs" rel="nofollow">http://www.google.com/$c$csearch#cZwlSNS7aEw/frameworks/base/core/java/android/widget/AbsoluteLayout.java&exact_package=android&q=AbsoluteLayout&type=cs

不过,得到这个code,第一,我改变了所有的mPadding(方向)getPadding(方向),但仍有上的LayoutParams构造一个错误:

But getting this code, first, I changed all the mPadding(Direction) to getPadding(Direction), but there's still an error on the LayoutParams constructor:

    public LayoutParams(Context c, AttributeSet attrs) {
        super(c, attrs);
        TypedArray a = c.obtainStyledAttributes(attrs,
                com.android.internal.R.styleable.AbsoluteLayout_Layout);
        x = a.getDimensionPixelOffset(
                com.android.internal.R.styleable.AbsoluteLayout_Layout_layout_x, 0);
        y = a.getDimensionPixelOffset(
                com.android.internal.R.styleable.AbsoluteLayout_Layout_layout_y, 0);
        a.recycle();
    }

com.android.internal.R cannot be resolved to a variable

我怎样才能获得这些价值?或者有人已经拥有此类独立于不属于谷歌希望保持对API?

How can I get these values? Or someone already has this class independently that don't belong to google wishes to keep on the API?

推荐答案

您需要复制了声明-设置样式条目从<一个href="http://www.google.com/$c$csearch#cZwlSNS7aEw/frameworks/base/core/res/res/values/attrs.xml&type=cs&l=2360"><$c$c>attrs.xml:

You need to copy over declare-styleable entry from attrs.xml:

<declare-styleable name="AbsoluteLayout_Layout">
    <attr name="layout_x" format="dimension" />
    <attr name="layout_y" format="dimension" />
</declare-styleable>

只需添加 RES /价值/ attrs.xml 文件到您的应用程序,并复制以上线路出现。

Just add res/values/attrs.xml file to your application and copy above lines there.

在这样做,更新您的code引用研究从你的包:

When this is done, update your code to reference R from your package:

import com.your.package.R;
...
public LayoutParams(Context c, AttributeSet attrs) {
    super(c, attrs);
    TypedArray a = c.obtainStyledAttributes(attrs,
            R.styleable.AbsoluteLayout_Layout);
    x = a.getDimensionPixelOffset(
            R.styleable.AbsoluteLayout_Layout_layout_x, 0);
    y = a.getDimensionPixelOffset(
            R.styleable.AbsoluteLayout_Layout_layout_y, 0);
    a.recycle();
}

这篇关于问题复制AbsoluteLayout - com.android.internal.R不能得到解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆