Someone submitted the bug Description: http://code.google.com/p/android/issues/detail? Id = 3484
Symptom: If you add linearlayout as a view to the root directory, but this linearlayout does not have a subview,
The following error is returned during running:
21:50:44 06-18. 020: Error/androidruntime (28605):> JAVA. lang. runtimeexception: mbaselinealignedchildindex of linearlayout> set to an index that is out of bounds.> 21:50:44 06-18. 020: Error/androidruntime (28605): At> android. widget. linearlayout. getbaseline (linearlayout. java: 151)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. widget. linearlayout. measurehorizontal (linearlayout. java: 644)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. widget. linearlayout. onmeasure (linearlayout. java: 280)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. view. view. measure (view. java: 7712)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. view. viewgroup. measurechildwithmargins (viewgroup. java: 3044)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. widget. linearlayout. measurechildbeforelayout (linearlayout. java: 888)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. widget. linearlayout. measurevertical (linearlayout. java: 350)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. widget. linearlayout. onmeasure (linearlayout. java: 278)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. view. view. measure (view. java: 7712)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. view. viewgroup. measurechildwithmargins (viewgroup. java: 3044)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. widget. framelayout. onmeasure (framelayout. java: 245)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. view. view. measure (view. java: 7712)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. view. viewgroup. measurechildwithmargins (viewgroup. java: 3044)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. widget. framelayout. onmeasure (framelayout. java: 245)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. view. view. measure (view. java: 7712)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. view. viewroot. extends mtraversals (viewroot. java: 824)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. view. viewroot. handlemessage (viewroot. java: 1774)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. OS. handler. dispatchmessage (handler. java: 99)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. OS. logoff. loop (logoff. java: 123)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> android. app. activitythread. main (activitythread. java: 4321)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> JAVA. lang. reflect. method. invokenative (native method)> 21:50:44 06-18. 020: Error/androidruntime (28605): At> JAVA. lang. reflect. method. invoke (method. java: 521)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> COM. android. internal. OS. zygoteinit $ methodandargscaller. run (zygoteinit. java: 791)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> COM. android. internal. OS. zygoteinit. main (zygoteinit. java: 549)> 06-18 21:50:44. 020: Error/androidruntime (28605): At> Dalvik. system. nativestart. main (native method)
This error occurs because the default value of the member variable in linearlayout is incorrect,
/**
* If this layout is part of another layout that is baseline aligned,
* Use the child at this index as the baseline.
*
* Note: This is orthogonal {@ Link# Mbaselinealigned}, which is concerned
* With whether the children of this layout are baseline aligned.
*/
Private IntMbaselinealignedchildindex= 0;
2.0 (it is estimated that a revision in the middle has been corrected, but the specific version is not known). Then the SDK fixes this problem:
/**
* If this layout is part of another layout that is baseline aligned,
* Use the child at this index as the baseline.
*
* Note: This is orthogonal { @ Link # Mbaselinealigned}, which is concerned
* With whether the children of this layout are baseline aligned.
*/
@ Viewdebug. exportedproperty (Category = " Layout " )
Private Int Mbaselinealignedchildindex = - 1 ;
:-), It is a problem caused by a default value. In this case, the linearlayout can be used instead of the View control.
The exception is thrown:
@ Override
Public Int Getbaseline (){
If (Mbaselinealignedchildindex < 0 ){
Return Super . Getbaseline ();
}
If (Getchildcount () <= Mbaselinealignedchildindex ){
Throw New Runtimeexception ( " Mbaselinealignedchildindex of linearlayout "
+ " Set to an index that is out of bounds. " );
}
Final View child = Getchildat (mbaselinealignedchildindex );
Final Int Childbaseline = Child. getbaseline ();
...