-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColorFragment.java
73 lines (51 loc) · 1.77 KB
/
ColorFragment.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package coms.example.k00na.radiobuttonsvaja;
import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioGroup;
/**
* Created by k00na on 17.5.2015.
*/
public class ColorFragment extends Fragment {
RadioGroup colorButtons;
colorChangedListener interfaceObject;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view;
view = inflater.inflate(R.layout.radio_group_layout, container, false);
colorButtons = (RadioGroup)view.findViewById(R.id.buttonsGroup);
colorButtons.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch(checkedId){
case R.id.red_button:
interfaceObject.getThatColor("RED");
break;
case R.id.blue_button:
interfaceObject.getThatColor("BLUE");
break;
case R.id.green_button:
interfaceObject.getThatColor("GREEN");
break;
}
}
});
return view;
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try{
interfaceObject = (colorChangedListener)activity;
} catch (Exception e){
}
}
public interface colorChangedListener{
public void getThatColor(String colorName);
}
}