Android停止運行問題1_layout布局xml問題

來源:互聯網
上載者:User

標籤:

  好好的寫了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             <RadioButton14                 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             <RadioButton16                 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問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.