請與本Scala的類幫助我,我要實現它的Java這裏,它是:Scala的類的Java
class StretchVideoView(context:Context, attr:AttributeSet)
extends VideoView(context, attrib) {
def measure(measureSpec:Int):Int = {
val specMode = View.MeasureSpec.getMode(measureSpec)
View.MeasureSpec.getSize(measureSpec)
}
override def onMeasure(widthMeasureSpec:Int, heightMeasureSpec:Int) {
val (w,h) = (measure(widthMeasureSpec), measure(heightMeasureSpec))
getHolder().setFixedSize(w,h)
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
}
}
我也試圖在這裏做我自己是我的Java代碼:
class StretchVideoView extends VideoView {
public StretchVideoView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public int measure(int measureSpec) {
int specMode = View.MeasureSpec.getMode(measureSpec)
??? View.MeasureSpec.getSize(measureSpec); // may be + here ???
return specMode; // ???
}
// and I'm not sure about this
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int w = measure(widthMeasureSpec);
int h = measure(heightMeasureSpec);
getHolder().setFixedSize(w,h);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
任何建議如何在Java上實現它?
這裏是原來的文章,此代碼: original code
'返回View.MeasuresSpect.getSize(..)'和「沒關係」。 – 2013-03-26 20:38:23