码迷,mamicode.com
首页 > 移动开发 > 详细

Android - Layout时发生'Unfortunately xxx has stopped'

时间:2014-12-05 07:03:47      阅读:259      评论:0      收藏:0      [点我收藏+]

标签:android   style   blog   http   io   ar   color   os   sp   

概述

  我在进行LinearLayout和TableLayout的嵌套布局的时候,发生题的错误.如下布局xml代码:

bubuko.com,布布扣
 1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 2     android:layout_width="fill_parent"
 3     android:layout_height="fill_parent"
 4     android:orientation="vertical" >
 5 
 6     <LinearLayout
 7         android:layout_width="fill_parent"
 8         android:layout_height="fill_parent"
 9         android:layout_weight="1"
10         android:orientation="horizontal" >
11 
12         <TextView
13             android:layout_width="wrap_content"
14             android:layout_height="fill_parent"
15             android:layout_weight="1"
16             android:background="#996699"
17             android:gravity="center"
18             android:text="one" />
19 
20         <TextView
21             android:layout_width="wrap_content"
22             android:layout_height="fill_parent"
23             android:layout_weight="1"
24             android:background="#FFFF99"
25             android:gravity="center"
26             android:text="two" />
27 
28         <TextView
29             android:layout_width="wrap_content"
30             android:layout_height="fill_parent"
31             android:layout_weight="1"
32             android:background="#CC9966"
33             android:gravity="center"
34             android:text="three" />
35 
36         <TextView
37             android:layout_width="wrap_content"
38             android:layout_height="fill_parent"
39             android:layout_weight="1"
40             android:background="#CCCC99"
41             android:gravity="center"
42             android:text="four" />
43     </LinearLayout>
44 
45     <LinearLayout
46         android:layout_width="fill_parent"
47         android:layout_height="fill_parent"
48         android:layout_weight="1"
49         android:orientation="vertical" >
50 
51         <TableLayout>
52 
53             <TableRow>
54 
55                 <TextView
56                     android:layout_width="fill_parent"
57                     android:layout_height="wrap_content"
58                     android:layout_weight="1"
59                     android:background="#993333"
60                     android:gravity="center"
61                     android:text="five" />
62 
63                 <TextView
64                     android:layout_width="fill_parent"
65                     android:layout_height="wrap_content"
66                     android:layout_weight="1"
67                     android:background="#CCCCCC"
68                     android:gravity="center"
69                     android:text="six" />
70             </TableRow>
71 
72             <TableRow>
73 
74                 <TextView
75                     android:layout_width="fill_parent"
76                     android:layout_height="wrap_content"
77                     android:layout_weight="1"
78                     android:background="#FFFF99"
79                     android:gravity="center"
80                     android:text="seven" />
81             </TableRow>
82         </TableLayout>
83     </LinearLayout>
84 
85 </LinearLayout>
View Code

   其中,应该在第51行中,TableLayout加上‘layout_width‘和‘layout_height‘属性.即可.如下(第46/47行):

bubuko.com,布布扣
 1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 2     android:layout_width="fill_parent"
 3     android:layout_height="fill_parent"
 4     android:orientation="vertical" >
 5 
 6     <LinearLayout
 7         android:layout_width="fill_parent"
 8         android:layout_height="fill_parent"
 9         android:layout_weight="1"
10         android:orientation="horizontal" >
11 
12         <TextView
13             android:layout_width="wrap_content"
14             android:layout_height="fill_parent"
15             android:layout_weight="1"
16             android:background="#996699"
17             android:gravity="center"
18             android:text="one" />
19 
20         <TextView
21             android:layout_width="wrap_content"
22             android:layout_height="fill_parent"
23             android:layout_weight="1"
24             android:background="#FFFF99"
25             android:gravity="center"
26             android:text="two" />
27 
28         <TextView
29             android:layout_width="wrap_content"
30             android:layout_height="fill_parent"
31             android:layout_weight="1"
32             android:background="#CC9966"
33             android:gravity="center"
34             android:text="three" />
35 
36         <TextView
37             android:layout_width="wrap_content"
38             android:layout_height="fill_parent"
39             android:layout_weight="1"
40             android:background="#CCCC99"
41             android:gravity="center"
42             android:text="four" />
43     </LinearLayout>
44 
45     <LinearLayout
46         android:layout_width="fill_parent"
47         android:layout_height="fill_parent"
48         android:layout_weight="1"
49         android:orientation="vertical" >
50 
51         <TableLayout
52             android:layout_width="fill_parent"
53             android:layout_height="fill_parent" >
54 
55             <TableRow>
56 
57                 <TextView
58                     android:layout_width="fill_parent"
59                     android:layout_height="wrap_content"
60                     android:layout_weight="1"
61                     android:background="#993333"
62                     android:gravity="center"
63                     android:text="five" />
64 
65                 <TextView
66                     android:layout_width="fill_parent"
67                     android:layout_height="wrap_content"
68                     android:layout_weight="1"
69                     android:background="#CCCCCC"
70                     android:gravity="center"
71                     android:text="six" />
72             </TableRow>
73 
74             <TableRow>
75 
76                 <TextView
77                     android:layout_width="fill_parent"
78                     android:layout_height="wrap_content"
79                     android:layout_weight="1"
80                     android:background="#FFFF99"
81                     android:gravity="center"
82                     android:text="seven" />
83             </TableRow>
84         </TableLayout>
85     </LinearLayout>
86 
87 </LinearLayout>
View Code

 

Android - Layout时发生'Unfortunately xxx has stopped'

标签:android   style   blog   http   io   ar   color   os   sp   

原文地址:http://www.cnblogs.com/listened/p/4145692.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!