精品丰满熟女一区二区三区_五月天亚洲欧美综合网_亚洲青青青在线观看_国产一区二区精选

  • <menu id="29e66"></menu>

    <bdo id="29e66"><mark id="29e66"><legend id="29e66"></legend></mark></bdo>

  • <pre id="29e66"><tt id="29e66"><rt id="29e66"></rt></tt></pre>

      <label id="29e66"></label><address id="29e66"><mark id="29e66"><strike id="29e66"></strike></mark></address>
      學(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