<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          自學(xué)鴻蒙應(yīng)用開發(fā)(38)- 修改RadioButton默認動作

          鴻蒙系統(tǒng)中RadionButton的默認動作是點擊某個選項時出現(xiàn)選中標(biāo)記,再次點擊時取消選中狀態(tài),表現(xiàn)如下面視頻中的第一排RadioButton。有時可能希望再次點擊時可以維持選中狀態(tài),就像下面視頻中第二排RadioButton那樣。


          布局文件

          文件中簡單地放置了兩個包含3個RadioButton的RadioContainer。

          <?xml version="1.0" encoding="utf-8"?><DirectionalLayout    xmlns:ohos="http://schemas.huawei.com/res/ohos"    ohos:height="match_parent"    ohos:width="match_parent"    ohos:orientation="vertical">    <RadioContainer        ohos:id="$+id:radio_container1"        ohos:height="match_content"        ohos:width="match_content"        ohos:top_margin="32vp"        ohos:orientation="horizontal"        ohos:layout_alignment="horizontal_center">        <RadioButton            ohos:id="$+id:radio_button_1"            ohos:height="40vp"            ohos:width="match_content"            ohos:text="A.Learning"            ohos:text_size="14fp"/>        <RadioButton            ohos:id="$+id:radio_button_2"            ohos:height="40vp"            ohos:width="match_content"            ohos:text="B.Innovation"            ohos:text_size="14fp"/>        <RadioButton            ohos:id="$+id:radio_button_3"            ohos:height="40vp"            ohos:width="match_content"            ohos:text="C.Benefit"            ohos:text_size="14fp"/>    </RadioContainer>    <RadioContainer        ohos:id="$+id:radio_container2"        ohos:height="match_content"        ohos:width="match_content"        ohos:top_margin="32vp"        ohos:orientation="horizontal"        ohos:layout_alignment="horizontal_center">        <RadioButton            ohos:id="$+id:radio_huawei"            ohos:height="60vp"            ohos:width="match_content"            ohos:text="H.Huawei"            ohos:text_size="14fp"/>        <RadioButton            ohos:id="$+id:radio_xiaomi"            ohos:height="60vp"            ohos:width="match_content"            ohos:text="X.Xiaomi"            ohos:text_size="14fp"/>        <RadioButton            ohos:id="$+id:radio_oppo"            ohos:height="60vp"            ohos:width="match_content"            ohos:text="O.Oppo"            ohos:text_size="14fp"/>    </RadioContainer></DirectionalLayout>


          修改RadionButton的行為

          下面的代碼在RadioButton的選中狀態(tài)發(fā)生變化時修改按鈕是否接受單擊的屬性。

          public class MainAbilitySlice extends AbilitySlice {    @Override    public void onStart(Intent intent) {        super.onStart(intent);        super.setUIContent(ResourceTable.Layout_ability_main);        AbsButton.CheckedStateChangedListener listener = new AbsButton.CheckedStateChangedListener() {            @Override            public void onCheckedChanged(AbsButton absButton, boolean b) {                absButton.setClickable(!b);            }        };        RadioButton rb1 = (RadioButton)findComponentById(ResourceTable.Id_radio_huawei);        rb1.setCheckedStateChangedListener(listener);        RadioButton rb2 = (RadioButton)findComponentById(ResourceTable.Id_radio_xiaomi);        rb2.setCheckedStateChangedListener(listener);        RadioButton rb3 = (RadioButton)findComponentById(ResourceTable.Id_radio_oppo);        rb3.setCheckedStateChangedListener(listener);    }}


          參考代碼

          完整代碼可以從以下鏈接下載:

          https://github.com/xueweiguo/Harmony/tree/master/RadioButtonTest

          作者著作介紹

          《實戰(zhàn)Python設(shè)計模式》是作者去年3月份出版的技術(shù)書籍,該書利用Python 的標(biāo)準(zhǔn)GUI 工具包tkinter,通過可執(zhí)行的示例對23 個設(shè)計模式逐個進行說明。這樣一方面可以使讀者了解真實的軟件開發(fā)工作中每個設(shè)計模式的運用場景和想要解決的問題;另一方面通過對這些問題的解決過程進行說明,讓讀者明白在編寫代碼時如何判斷使用設(shè)計模式的利弊,并合理運用設(shè)計模式。

          對設(shè)計模式感興趣而且希望隨學(xué)隨用的讀者通過本書可以快速跨越從理解到運用的門檻;希望學(xué)習(xí)Python GUI 編程的讀者可以將本書中的示例作為設(shè)計和開發(fā)的參考;使用Python 語言進行圖像分析、數(shù)據(jù)處理工作的讀者可以直接以本書中的示例為基礎(chǔ),迅速構(gòu)建自己的系統(tǒng)架構(gòu)。




          覺得本文有幫助?請分享給更多人。

          關(guān)注微信公眾號【面向?qū)ο笏伎肌枯p松學(xué)習(xí)每一天!

          面向?qū)ο箝_發(fā),面向?qū)ο笏伎迹?/span>



          瀏覽 62
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  国产白丝在线观看 | 乱伦性爱视频 | 高清无码免费观看 | 影音先锋亚洲成人 | 久热小视频 |