<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ToggleButton、Switch、CheckBox和RadioButton都是繼承自android.widget.CompoundButton,意思是可選擇的,因此它們的用法都很類似。CompoundButton有兩個狀態,分別是checked和not checked。 ToggleButton的屬性: ![](https://box.kancloud.cn/2016-03-10_56e0d9a90f62e.jpg) ![](https://box.kancloud.cn/2016-03-10_56e0d9a927fab.jpg) Switch組件的屬性: ![](https://box.kancloud.cn/2016-03-10_56e0d9a93af86.jpg) android:thumb是選中時的背景 例:開關按鈕控制布局方向 main.xml ~~~ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ToggleButton android:id="@+id/toggleButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="ToggleButton" android:textOff="橫向排列" android:textOn="縱向排列" /> <!-- android:thumb="@drawable/check" 使用自定義的drawable對象繪制開關按鈕 --> <Switch android:id="@+id/switch1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Switch" android:textOff="橫向排列" android:textOn="縱向排列" android:thumb="@drawable/check" /> <LinearLayout android:id="@+id/root" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button1" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button2" /> <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button3" /> </LinearLayout> </LinearLayout> ~~~ MainActivity.java ~~~ ToggleButton toggle; Switch switcher; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toggle=(ToggleButton) findViewById(R.id.toggleButton1); switcher=(Switch) findViewById(R.id.switch1); final LinearLayout test=(LinearLayout) findViewById(R.id.root); //ToggleButton和Switch的監聽接口和復選框CheckButton的一樣 CompoundButton.OnCheckedChangeListener listener=new CompoundButton.OnCheckedChangeListener(){ @Override public void onCheckedChanged(CompoundButton button, boolean checkedId) { // TODO Auto-generated method stub if(checkedId){ //1表示垂直布局,0表示水平布局 test.setOrientation(1); }else{ test.setOrientation(0); } } }; toggle.setOnCheckedChangeListener(listener); switcher.setOnCheckedChangeListener(listener); } ~~~ ![](https://box.kancloud.cn/2016-03-10_56e0d9a94e0da.jpg) ![](https://box.kancloud.cn/2016-03-10_56e0d9a96cf20.jpg) 以后要學會自己定制跟家美觀的組件 推薦幾個好的博客: [http://blog.csdn.net/billpig/article/details/6634481](http://blog.csdn.net/billpig/article/details/6634481) [http://blog.csdn.net/luoweifu/article/details/11752035](http://blog.csdn.net/luoweifu/article/details/11752035)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看