導航:首頁 > 操作系統 > androidradiogroup默認

androidradiogroup默認

發布時間:2023-06-12 06:46:43

『壹』 android如何動態生成Radio和RadioGroup

privateLinearLayoutlayout;//布局,可以在xml布局中獲得

privateRadioGroupgroup;//點選按鈕組

publicvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

layout=newLinearLayout(this);//實例化布局對象

group=newRadioGroup(this);//實例化單選按鈕組

//添加單選按鈕

for(inti=0;i<5;i++){

RadioButtonradio=newRadioButton(this);

radio.setText("radio"+i);

group.addView(radio);

}

//將單選按鈕組添加到布局中

layout.addView(group);

this.setContentView(layout);

}

可以把單選按鈕組放在ScrollView中,這樣的話,多出的部分可以滾動查看了。

『貳』 android RadioButton怎麼設置默認選中

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

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

『叄』 android radiogroup怎麼初始化按鈕

請說明完整你的問題。
RadioButton carButton = (RadioButton) findViewById(R.id.search_car);
RadioButton busButton = (RadioButton) findViewById(R.id.search_bus);
RadioButton walkButton = (RadioButton) findViewById(R.id.search_walk);
以上是三個button的初始化,也就是找到改按鈕。
如果需要設置某個按鈕是被選中的
請調用performClick();方法
例如:
carButton.performClick();

閱讀全文

與androidradiogroup默認相關的資料

熱點內容
有什麼好用的陪聊app 瀏覽:698
什麼是備中心伺服器 瀏覽:144
linux配置本地yum源 瀏覽:539
半導體器件與工藝pdf 瀏覽:528
超大文件解壓太慢 瀏覽:861
微光app主頁的愛心代表什麼意思 瀏覽:563
程序員和餃子做飯 瀏覽:307
美團app的點擊騎車在哪裡 瀏覽:723
程序員標配條件 瀏覽:211
免費電腦解壓app排行榜前十名 瀏覽:189
順序表查找演算法 瀏覽:463
整合包解壓後是亂碼 瀏覽:300
xp系統如何查找伺服器名 瀏覽:983
土的壓縮系數的確定方法 瀏覽:647
程序員家裡健身 瀏覽:620
電視看籃球app哪個好 瀏覽:47
高中畢業當程序員 瀏覽:245
php標簽屬性大全 瀏覽:897
遠程訪問伺服器ip地址 瀏覽:313
程序員吃雞蛋炒菜 瀏覽:174