首页 > 移动平台 > 详细

Android停止运行问题1_layout布局xml问题

时间:2016-07-31 17:38:47      阅读:294      评论:0      收藏:0      [点我收藏+]

  好好的写了300多行布局文件代码,写完之后运行结果,停止运行了。我当时就奇怪,xml有错误应该会提示啊,我就一个一个的缩小错误的代码范围,先直接换成一个简单的TextView ,运行一下没有错误。再慢慢增加代码,直到增加到一个RadioGroup,直接停止运行

原来的代码是这样

 1 <RadioGroup
 2             android:id="@+id/rgSex"
 3             android:orientation="horizontal"
 4             android:layout_gravity="center_horizontal">
 5 
 6             <RadioButton
 7                 android:layout_height="wrap_content"
 8                 android:layout_width="wrap_content"
 9                 android:text="男"
10                 android:checked="true"
11                 android:id="@+id/male"/>
12 
13             <RadioButton
14                 android:layout_height="wrap_content"
15                 android:layout_width="wrap_content"
16                 android:text="女"
17                 android:id="@+id/female"/>
18 
19         </RadioGroup>

当时我不知道错在哪,我找人求助,别人告诉我,RadioGroup要设置layout_height ,layout_width 我才明白

改成这样就可以了

 1         <RadioGroup
 2             android:layout_height="wrap_content"
 3             android:layout_width="wrap_content"
 4             android:id="@+id/rgSex"
 5             android:orientation="horizontal"
 6             android:layout_gravity="center_horizontal">
 7 
 8             <RadioButton
 9                 android:layout_height="wrap_content"
10                 android:layout_width="wrap_content"
11                 android:text="男"
12                 android:checked="true"
13                 android:id="@+id/male"/>
14 
15             <RadioButton
16                 android:layout_height="wrap_content"
17                 android:layout_width="wrap_content"
18                 android:text="女"
19                 android:id="@+id/female"/>
20 
21         </RadioGroup>

 

Android停止运行问题1_layout布局xml问题

原文:http://www.cnblogs.com/ncgds/p/5723224.html

(0)
(5)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!