代码之家  ›  专栏  ›  技术社区  ›  F.Fipoo

如何设置打开前检查的微调器

  •  -2
  • F.Fipoo  · 技术社区  · 7 年前

    我不知道如何设置选中的默认项。

    screen

    <com.toptoche.searchablespinnerlibrary.SearchableSpinner
                    android:spinnerMode="dialog"
                    android:id="@+id/sex"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_conten"/>
    
        <com.toptoche.searchablespinnerlibrary.SearchableSpinner
                    android:spinnerMode="dialog"
                    android:id="@+id/category"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_conten"/>
    

    在课堂上

                final ArrayAdapter<String> adapterSex = new ArrayAdapter<String>(
                                SearchActivity.this,
                                android.R.layout.simple_list_item_single_choice,
                                listSex);
    
                sexS.setAdapter(adapterSex);
    
               final ArrayAdapter<String> adapterCategory = new ArrayAdapter<String(
                                SearchActivity.this,
                                android.R.layout.simple_list_item_single_choice,
                                listCategory);
    
                categoryS.setAdapter(adapterCategory);
    
    0 回复  |  直到 7 年前
        1
  •  0
  •   Julxzs Danny Herbert    7 年前

    您可以在java中键入:

    CheckBox checkBox = (CheckBox) findViewById(R.id.checkbox1);
    if (checkBox.isChecked()) {
        checkBox.setChecked(false);
    }
    

    或XML格式:

    android:checked="false"