문제

I am reviewing the ProgressBar.java sourcecode from Android's SDK. On line 191 of android.widget.ProgressBar it states:

 mMinHeight = a.getDimensionPixelSize(R.styleable.ProgressBar_minHeight, mMinHeight));

Why is it using mMinHeight in the parameter list at the same time as it is initializing it?? Can someone shed light on this? The full sourcecode can be located here at grepcode.

도움이 되었습니까?

해결책

See on line 171 where it calls initProgressBar? That method initializes mMinHeight to the value of 24. Then the call to getDimensionPixelSize uses that as the default value.

다른 팁

The second parameter is just a default value that should be returned if getDimensionPixelSize is not able to find the requested value. It's common (if slightly weird) to pass in the variable you're attempting to set as the default value. Effectively, this code says "set this value if you have it, or just leave the variable as it is if you don't".

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top