Monday, July 31, 2017

RadioGroup ​​ေျခခံ သင္​ခန္​းစာ

main.xml
@@@@@@

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RadioGroup
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/radioGroup">

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Red"
            android:id="@+id/radioButton1Id"/>

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Yellow"
            android:id="@+id/radioButton2Id" />

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Magenta"
            android:id="@+id/radioButton3Id" />

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Cyan"
            android:id="@+id/radioButton4Id" />
    </RadioGroup>

</RelativeLayout>

MainActivity.java
@@@@@@@@@

import android.os.Bundle;
import android.view.View;
import android.app.*;
import android.widget.*;
import android.graphics.*;

public class MainActivity extends Activity {
RadioGroup b;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

b= (RadioGroup) findViewById(R.id.radioGroup);
        b.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
switch (i){
case R.id.radioButton1Id:
getWindow().getDecorView().setBackgroundColor(Color.parseColor("#FF0000"));
break;
case R.id.radioButton2Id:
getWindow().getDecorView().setBackgroundColor(Color.parseColor("#FFFF00"));
break;
case R.id.radioButton3Id:
getWindow().getDecorView().setBackgroundColor(Color.parseColor("#FF00FF"));
break;
case R.id.radioButton4Id:
getWindow().getDecorView().setBackgroundColor(Color.parseColor("#00FFFF"));
break;
}
}
});
}

}

...........
This is BMMA Lessons For Android

No comments:

Post a Comment

UI Vs UX ဘ​ာေတြ ကြာသလဲ?

Ui Vs Ux  (About) Original .Creativo 27 Next Next Next Next Thank you for reading . Bhone Myint ...