導航:首頁 > 操作系統 > android單選框

android單選框

發布時間:2022-01-11 18:54:10

android怎麼設置單選按鈕默認值

android怎麼設置單選按鈕默認值:android:checked="true"選中狀態。

Ⅱ Android EditText單擊彈出單選框對話框..急...

點擊edittext的觸發新建dialog事件 給你一小段代碼
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("請選擇哪位美女");//標題
builder.setCancelable(false);// 是否可退出
builder.setSingleChoiceItems(itemstr, 0,
new DialogInterface.OnClickListener() { // itemstr就是一個string[] 類型的一位數組,就是你給出去的那些選擇項 ,0是默認選擇哪個
public void onClick(DialogInterface dialog, int item) {
//自己再Create()

Ⅲ 安卓開發 單選對話框實現跳轉

AlertDialog Builder=new AlertDialog.Builder(Aone.this).setTitle("單選框")
.setSingleChoiceItems(
new String[] { "青少年", "成年人","中年人","老年人" }, 0,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// dialog.dismiss();
//這里就是你要寫的地方onclick()裡面的which就是你點擊單選框的索引
//如果你想點擊青少年的時候跳轉,就判斷一下
if(which==0){
Intent objIntent = new Intent();

。。。。就不寫了

}
}
}).setNegativeButton("確定", null).show();

Ⅳ Android Studio 單選按鈕

是的,沒錯,能單獨拿出來拿出來用,要用RadioGroup包起來,代表一個組嘛,道理很簡單。CheckBox可以單獨出來。

用法是這樣的

<RadioGroup....>
<RadioButton.../>
<RadioButton.../>
<RadioButton.../>
<RadioButton.../>
......
</RadioGroup>

Ⅳ android怎麼讓復選框實現單選框功能

1單擊左上角office圖標。選擇彈出的對話框的 右下角的 word選項 2.在 word選項卡中選擇 在功能區顯示開發工具選項卡 打勾,確定。 3.在菜單欄中找到開發工具選項卡。。。在控制項的欄中。選擇控制項。單眩復眩下拉菜單等等都在 這里 。

Ⅵ 請問android 編程中可不可以自定義單選框,怎樣實現。謝謝!

可以,使用style就行了,自定義style後就可以去掉自帶的圓圈圈,在設置背景的時候會使用到shape,使用shape設置按下狀態等等

Ⅶ android 編程中怎樣從單選按鈕獲取數據

java">this.sex=(RadioGroup)super.findViewById(R.id.sex);
this.male=(RadioButton)super.findViewById(R.id.male);
this.female=(RadioButton)super.findViewById(R.id.female);
this.sex.setOnCheckedChangeListener(newOnCheckedChangeListenerImp());

r{

publicvoidonCheckedChanged(RadioGroupgroup,intcheckedId){
Stringtemp=null;
if(MainActivity.this.male.getId()==checkedId){
temp="男";
}
elseif(MainActivity.this.female.getId()==checkedId){
temp="女";
}

RadioButton是android開發中常見的一種控制項,而使用簡單,通常與RadioGroup一起使用。RadioButton表示單個圓形單選框,而RadioGroup是可以容納多個RadioButton的容器。

Ⅷ android中的checkBox如何實現單選

Android中checkbox默認為復選框,也就是多選,實現單選的話,可以讓checkbox添加監聽,當已經有一個點擊了,點擊另外一個的時候,修改默認的狀態,實現單選,示例如下:

publicstaticinttemp=-1;
checkBox=(CheckBox)parentView.findViewById(R.id.cbox_isselect);
//做個標記
checkBox.setId(groupPosition);
//checkbox監聽
checkBox.setOnCheckedChangeListener(newOnCheckedChangeListener(){
@Override
publicvoidonCheckedChanged(CompoundButtonbuttonView,booleanisChecked){
if(isChecked)
{
//這段代碼來實現單選功能
if(temp!=-1)
{
CheckBoxtempButton=(CheckBox)MyRingBoxActivity.this.findViewById(temp);
if(tempButton!=null)
{
tempButton.setChecked(false);
}
}
//得到當前的position
temp=buttonView.getId();
}else{
temp=-1;
}

}
});

Ⅸ android RadioButton怎麼設置默認選中

android RadioButto這個控制項是不能設置默認選中的,因為這個是谷歌公司源碼中規定的要想設置為選中狀態,需要手動添加一個屬性,屬性為checked,把該屬性設置為true,設置方法如下:

1、使用Android studio創建一個項目,如下圖:

Ⅹ 如何實現android中三個單選按鈕橫向排列且只能選一個

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/row_item_margin">

<TextView
android:id="@+id/tvStorageWay"
style="@style/EditTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="儲存方式:"/>

<RadioGroup
android:id="@+id/rgStorageWay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/tvStorageWay"
android:gravity="center_vertical"
android:orientation="horizontal">

<RadioButton
android:id="@+id/rbPack"
style="@style/EditTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@null"
android:drawableLeft="@drawable/selector_login_mode_radiobutton"
android:text="包裝"/>

<RadioButton
android:id="@+id/rbBulk"
style="@style/EditTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/row_item_margin"
android:layout_weight="1"
android:button="@null"
android:drawableLeft="@drawable/selector_login_mode_radiobutton"
android:text="散裝"/>

<RadioButton
android:id="@+id/rbStorageWayOther"
style="@style/EditTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/row_item_margin"
android:layout_weight="1"
android:button="@null"
android:drawableLeft="@drawable/selector_login_mode_radiobutton"
android:text="其它"/>
</RadioGroup>
</RelativeLayout>

閱讀全文

與android單選框相關的資料

熱點內容
phpsql單引號 瀏覽:82
英雄聯盟壓縮壁紙 瀏覽:450
辦公app需要什麼伺服器 瀏覽:626
安卓伺服器怎麼獲得 瀏覽:806
空調壓縮機冷媒的作用 瀏覽:779
淘寶app是以什麼為利的 瀏覽:655
java提取圖片文字 瀏覽:922
我的世界手機版指令復制命令 瀏覽:33
java判斷字元串為數字 瀏覽:924
androidrpc框架 瀏覽:488
雲伺服器essd和ssd 瀏覽:522
家用網關的加密方式 瀏覽:1
怎麼從ppt導出pdf文件 瀏覽:971
換汽車空調壓縮機軸承 瀏覽:845
平板怎麼登錄安卓端 瀏覽:195
圖像拼接計演算法 瀏覽:255
怎麼打開飢荒伺服器的本地文件夾 瀏覽:291
usb掃描槍編程 瀏覽:673
博易大師手機app叫什麼 瀏覽:663
刮眼影盤解壓方法 瀏覽:966