我尝试了几种方法来解决它,但没有任何作用。
首先,我将xmlns:app="http://schemas.android.com/apk/res/com.devmob.mediaequalizer"
添加到xml中的父节点。但是当我按 Ctrl + Space 时没有任何作用然后我发现如果app的目标大于17,则只需将xmlns:custom="http://schemas.android.com/apk/res-auto"
添加到父节点。
CustomView
public PotentiometerView(Context context)
{
super(context);
initialize();
}
public PotentiometerView(Context context, AttributeSet attributeset)
{
super(context, attributeset);
//get the attributes specified in attrs.xml using the name we included
TypedArray a = context.getTheme().obtainStyledAttributes(attributeset,
R.styleable.Potentiometer, 0, 0);
try
{
//get the text and colors specified using the names in attrs.xml
isEnable = a.getBoolean(R.styleable.Potentiometer_Potentiometer_enable, true);
max = a.getInteger(R.styleable.Potentiometer_Potentiometer_max, 100);//0 is default
int progresss = a.getInteger(R.styleable.Potentiometer_Potentiometer_progress, 0);
setProgress(progresss);
}
finally
{
a.recycle();
}
initialize();
}
public PotentiometerView(Context context, AttributeSet attributeset, int i)
{
super(context, attributeset, i);
initialize();
}
attrs.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="Potentiometer">
<attr name="Potentiometer_max" format="integer" />
<attr name="Potentiometer_progress" format="integer" />
<attr name="Potentiometer_enable" format="boolean" />
</declare-styleable>
</resource>
是否有任何解决此问题的方法。我的customView属性未显示在xml中。