導航:首頁 > 操作系統 > 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默認相關的資料

熱點內容
單片機rgb燈4腳 瀏覽:303
php執行mysql查詢 瀏覽:530
程序員在深圳找工作 瀏覽:572
江蘇伺服器託管虛擬主機雲伺服器 瀏覽:947
sqlplus未知的命令 瀏覽:771
linux串口shell 瀏覽:354
媒體文化pdf 瀏覽:253
linuxmysql資料庫目錄 瀏覽:315
命令方塊做水上鞋 瀏覽:551
python中可迭代的數列怎麼寫 瀏覽:75
python中geos安裝 瀏覽:967
將命令方塊替換成空氣 瀏覽:415
美德書中央編譯出版社pdf 瀏覽:460
真封神命令 瀏覽:295
linux命令實例 瀏覽:700
如何取消伺服器的密碼是什麼原因 瀏覽:578
php表格製作 瀏覽:413
液體的壓縮性 瀏覽:458
防sql注入方法python 瀏覽:274
只有我可以命令 瀏覽:795