安卓:如何声明设置样式在R.java? [英] Android: How to Declare Styleable in R.java?
问题描述
我试图用这个 ViewPager
扩展一>。这个插件可以帮助我使用 SwipeyTab
。我成功运行的例子作为一个单一的应用程序。所以我想在延长我的application.Then融入我coppied java文件和更改包名,一切都很好。但我有这些线路上的一些错误:
I'm trying to use this ViewPager
extension. This plugin helps me using SwipeyTab
. I succeed to run example as a single application. So I want to integrate extension in to my application.Then I coppied the java files and changed package names, everything is fine. But I've got some errors on these lines:
mTextColorCenter = a.getColor(R.styleable.ViewPagerExtensions_textColorSelected, mTextColorCenter);
mLineColorCenter = a.getColor(R.styleable.ViewPagerExtensions_lineColorSelected, mLineColorCenter);
mLineHeightSelected = a.getDimensionPixelSize(R.styleable.ViewPagerExtensions_lineHeightSelected, mLineHeightSelected);
Eclipse中说:设置样式不能得到解决或不是一个字段
。其中包含设置样式也有其他线条给人同样的错误了。如果我尝试点击解决这个问题,没有什么变化。
Eclipse says: Styleable cannot be resolved or is not a field
. Other lines which contains styleable also gives the same errors too. If I try to click solve this problem nothing changes.
当我看过扩展的R.java文件,我看到了这些行:
When I have looked at extension's R.java file, I saw these lines:
public static final class styleable {
public static final int[] ViewPagerExtensions = {
0x7f010000, 0x7f010001, 0x7f010002, 0x7f010003,
0x7f010004, 0x7f010005, 0x7f010006, 0x7f010007,
0x7f010008, 0x7f010009, 0x7f01000a
};
public static final int ViewPagerExtensions_dividerColor = 7;
// there is more
}
我知道这是不可能的编辑R.java。我怎么能在R.java定义设置样式为这个扩展?有什么建议?
I know it's not possible to edit R.java. How could I define styleable in R.java for this extension? Any suggestions?
推荐答案
您应该定义,属性,你要去的需要,在一个单独的XML文件中。我的意思是创建一个values.xml并使用<申报-设置样式名称=ViewPagerExtensions>< /申报,设置样式>
标记。
You should define, attributes that you gonna need, in a seperate xml file. I mean create a values.xml and use <declare-styleable name="ViewPagerExtensions"></declare-styleable>
tags.
让我举一个例子:
<declare-styleable name="ViewPagerExtensions">
<attr format="integer" name="dividerColor" />
</declare-styleable>
顺便说一句,已经有attrs.xml项目,的检查出来:
这篇关于安卓:如何声明设置样式在R.java?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!