Pai_^ is a bug in the android framework.

Source: Internet
Author: User

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 ();
...
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.