0
ScaleDrawable()を使用するときに構文エラーが発生します。私は間違ったことをする必要があります。 アイデア構文ScaleDrawable()を使用しているときのエラー
2エラー私はかなり修正できません。
この私が現時点で持っているものである:ここ
protected class testbuttonBackgroundDrawable extends LayerDrawable {
/** my aim - the image used as background for the custom view is increased in
*size by 25percent and then a yellow color filter is attached to it.
*This yellow image then has the original background image layered on top of it
*to create the effect of the image having a glow around it
*I want to use this later on for when the custom button has focus
*/
ColorFilter colourFilter = new LightingColorFilter(Color.YELLOW, 1);
ScaleDrawable resizedImage = new ScaleDrawable(background, 0, 1.25f, 1.25f);*
*エラーがある - トークンの構文エラー ";"、{*このトークン
nD = resizedImage.getDrawable();
nD.setColorFilter(colourFilter);
Drawable[] aD = new Drawable[2];
aD[0] = nD;
aD[1] = background;
LayerDrawable _highlightedDrawable = new LayerDrawable(aD);
//This will make the background image fade if the button is set to disabled
protected int _disabledAlpha = 100;
/**This is another scale drawable, this time used to shrink the background image of
*the custom button when it is pressed
*/
protected ScaleDrawable _pressedDrawable = new ScaleDrawable(background, 0, 0.75f, 0.75f);*
後に予想されるエラーはこちら - "構文エラー、挿入"} "ブロックを完了する"
public testbuttonBackgroundDrawable(Drawable d) {
super(new Drawable[] { d });
}
@Override
protected boolean onStateChange(int[] states) {
boolean enabled = false;
boolean highlighted = false;
boolean pressed = false;
for (int state : states) {
if (state == android.R.attr.state_enabled)
enabled = true;
else if (state == android.R.attr.state_selected)
highlighted = true;
else if (state == android.R.attr.state_pressed)
pressed = true;
}
mutate();
if (enabled && highlighted) {
setBackgroundDrawable(_highlightedDrawable); // buttons need transparent backgrounds
} else if (!enabled) {
setColorFilter(null);
setAlpha(_disabledAlpha);
} else if (enabled && pressed){
setBackgroundDrawable(_pressedDrawable);
} else {
setColorFilter(null);
}
invalidateSelf();
return super.onStateChange(states);
}
}
}
エラーを修正するための助けがあれば幸いです。
私はScaleDrawableコンストラクタを正しく使用していないと思います。
これを正しく行うにはどうすればよいですか?
これは問題ではない場合は、任意のヘルプをいただければ幸いです。