国产宅男网站在线|亚洲A级性爱免费视频|亚洲中精品级在线|午夜福利AA毛

  • <dd id="gf5jf"><th id="gf5jf"></th></dd>

    <cite id="gf5jf"><label id="gf5jf"></label></cite>
  • <div id="gf5jf"><listing id="gf5jf"></listing></div>
    學(xué)習(xí)啦 > 知識(shí)大全 > 知識(shí)百科 > 公共基礎(chǔ)知識(shí) > 安卓checkbox的用法Android平臺(tái)優(yōu)勢(shì)

    安卓checkbox的用法Android平臺(tái)優(yōu)勢(shì)

    時(shí)間: 謝君787 分享

    安卓checkbox的用法Android平臺(tái)優(yōu)勢(shì)

      安卓開(kāi)發(fā)中經(jīng)常會(huì)用到checkbox,那么具體是如何使用的呢?以下是由學(xué)習(xí)啦小編整理關(guān)于安卓checkbox的用法的內(nèi)容,希望大家喜歡!

      安卓checkbox的用法

      CheckBox定義一個(gè)同意協(xié)議的按鈕,只要同意button才可以點(diǎn)擊

      XML代碼

      <CheckBox

      android:id="@+id/checkbox1"

      android:layout_width="wrap_content"

      android:layout_height="wrap_content"

      android:layout_above="@+id/button1"

      android:layout_alignLeft="@+id/linearLayout1"

      android:text="牛仔"

      />

      在onClick里面設(shè)置只要當(dāng)checkbox.isChecked()為true,也就是勾選上時(shí),button1.setEnabled(true);才可以點(diǎn)擊

      java代碼

      checkbox = (CheckBox) findViewById(R.id.checkbox1);

      checkbox.setChecked(false);

      button1.setEnabled(false);

      checkbox.setOnClickListener(new CheckBox.OnClickListener(){

      <span style="white-space:pre"> </span>@Override

      public void onClick(View v) {

      // TODO Auto-generated method stub

      if(checkbox.isChecked()){

      button1.setEnabled(true);

      }else{

      <span style="white-space:pre"> </span>button1.setEnabled(false);

      }

      <span style="white-space:pre"> </span>}

      });

      定義多個(gè)CheckBox來(lái)控制同一個(gè)控件

      XML代碼

      <CheckBox

      android:id="@+id/checkbox1"

      android:layout_width="wrap_content"

      android:layout_height="wrap_content"

      android:layout_above="@+id/button1"

      android:layout_alignLeft="@+id/linearLayout1"

      android:text="牛仔"

      />

      <CheckBox

      android:id="@+id/checkbox2"

      android:layout_width="wrap_content"

      android:layout_height="wrap_content"

      android:layout_alignBaseline="@+id/checkbox3"

      android:layout_alignBottom="@+id/checkbox3"

      android:layout_marginLeft="27dp"

      android:layout_toRightOf="@+id/checkbox3"

      android:text="面包" />

      <CheckBox

      android:id="@+id/checkbox3"

      android:layout_width="wrap_content"

      android:layout_height="wrap_content"

      android:layout_alignBaseline="@+id/checkbox1"

      android:layout_alignBottom="@+id/checkbox1"

      android:layout_toRightOf="@+id/button1"

      android:text="黃油" />

    1697483