編輯:關於android開發
xml:
<RadioGroup android:id="@+id/group1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="radio1"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="radio2"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="radio3"/>
</RadioGroup>
<TextView android:text="你的選擇是:"
android:id="@+id/txtResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
java中的代碼:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView textView=(TextView)findViewById(R.id.txtResult);
RadioGroup radioGroup=(RadioGroup)findViewById(R.id.group1);
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
int radioButtonId=radioGroup.getCheckedRadioButtonId();
RadioButton rb=(RadioButton)helloworld.this.findViewById(radioButtonId);
textView.setText(rb.getText());
}
});
}
最終效果:
Apache Cordova開發Android應用程序——番外篇,cordovaandroid
Apache Cordova開發Android應用程序——番外篇,cordovaandroid 很多天之前就安裝了visual studio community 201
Android 實現圖片畫畫板,
Android 實現圖片畫畫板,本文主要講述了Android 實現圖片畫畫板 設計項目布局: <RelativeLayout xmlns:android=http
Android6.0系統增加那些新特性
Android6.0系統增加那些新特性 北京時間9月30日凌晨在美國舊金山舉行2015年秋季新品發布會。在發布會上代號為“Marshmallow(棉花糖)
Android學習指南之二十:Content Provider的使用
Content Provider屬於Android應用程序的組件之一,作為應用