Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DayOfWeek extends Fragment
- {
- private View rootView;
- private Switch toggle;
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
- {
- rootView = inflater.inflate(R.layout.fragment_dayofweek, container, false);
- toggle = (Switch) rootView.findViewById(R.id.hint_switch);
- toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
- {
- @Override
- public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked)
- {
- process();
- }
- });
- rootView.findViewById(R.id.button).setOnClickListener(new View.OnClickListener()
- {
- @Override
- public void onClick(View view)
- {
- process();
- }
- });
- return rootView;
- }
- private void process()
- {
- String day = ((EditText) rootView.findViewById(R.id.day)).getText().toString();
- String month = ((EditText) rootView.findViewById(R.id.month)).getText().toString();
- String year = ((EditText) rootView.findViewById(R.id.year)).getText().toString();
- if (!(Validator.isInteger(day) && Validator.isInteger(month) && Validator.isInteger(year))) {
- displayWarning();
- return;
- }
- if (ba.isDateValid()) {
- TextView tv = (TextView) rootView.findViewById(R.id.textView);
- tv.setText(result);
- tv.setTextAlignment((toggle.isChecked() ? View.TEXT_ALIGNMENT_TEXT_START : View.TEXT_ALIGNMENT_CENTER));
- Log.d("Toggle status", String.valueOf(toggle.isChecked()));
- Log.d("Alignment", String.valueOf((toggle.isChecked() ? View.TEXT_ALIGNMENT_TEXT_START : View.TEXT_ALIGNMENT_CENTER)));
- }
- else {
- displayWarning();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment