Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top