Android Open Source - datetimepicker-android Main Activity






From Project

Back to project page datetimepicker-android.

License

The source code is released under:

Apache License

If you think the Android project datetimepicker-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package jp.seesaa.example.datetimepicker;
/*from   ww  w  . j  av  a 2  s .c o m*/
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.View;
import android.widget.Toast;

import jp.seesaa.android.datetimepicker.date.DatePickerDialog;
import jp.seesaa.android.datetimepicker.time.RadialPickerLayout;
import jp.seesaa.android.datetimepicker.time.TimePickerDialog;


public class MainActivity extends FragmentActivity implements
        DatePickerDialog.OnDateSetListener,
        TimePickerDialog.OnTimeSetListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        findViewById(R.id.button1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DatePickerDialog.newInstance(MainActivity.this, 2006, 1, 2)
                        .show(getSupportFragmentManager(), "datepicker");
            }
        });

        findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                TimePickerDialog.newInstance(MainActivity.this, 12, 34, true)
                        .show(getSupportFragmentManager(), "timepicker");
            }
        });

        if (savedInstanceState != null) {
            final FragmentManager fm = getSupportFragmentManager();

            DatePickerDialog datePicker = (DatePickerDialog) fm.findFragmentByTag("datepicker");
            if (datePicker != null) {
                datePicker.setOnDateSetListener(this);
            }

            TimePickerDialog timePicker = (TimePickerDialog) fm.findFragmentByTag("timepicker");
            if (timePicker != null) {
                timePicker.setOnTimeSetListener(this);
            }
        }

    }

    @Override
    public void onDateSet(DatePickerDialog dialog, int year, int monthOfYear, int dayOfMonth) {
        Toast.makeText(this, String.format("onDateSet: %d/%d/%d", year, monthOfYear, dayOfMonth), Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onTimeSet(RadialPickerLayout view, int hourOfDay, int minute) {
        Toast.makeText(this, String.format("onTimeSet: %d:%d", hourOfDay, minute), Toast.LENGTH_SHORT).show();
    }
}




Java Source Code List

jp.seesaa.android.datetimepicker.AccessibleLinearLayout.java
jp.seesaa.android.datetimepicker.AccessibleTextView.java
jp.seesaa.android.datetimepicker.HapticFeedbackController.java
jp.seesaa.android.datetimepicker.Utils.java
jp.seesaa.android.datetimepicker.date.AccessibleDateAnimator.java
jp.seesaa.android.datetimepicker.date.DatePickerController.java
jp.seesaa.android.datetimepicker.date.DatePickerDialog.java
jp.seesaa.android.datetimepicker.date.DayPickerView.java
jp.seesaa.android.datetimepicker.date.MonthAdapter.java
jp.seesaa.android.datetimepicker.date.MonthView.java
jp.seesaa.android.datetimepicker.date.SimpleDayPickerView.java
jp.seesaa.android.datetimepicker.date.SimpleMonthAdapter.java
jp.seesaa.android.datetimepicker.date.SimpleMonthView.java
jp.seesaa.android.datetimepicker.date.TextViewWithCircularIndicator.java
jp.seesaa.android.datetimepicker.date.YearPickerView.java
jp.seesaa.android.datetimepicker.time.AmPmCirclesView.java
jp.seesaa.android.datetimepicker.time.CircleView.java
jp.seesaa.android.datetimepicker.time.RadialPickerLayout.java
jp.seesaa.android.datetimepicker.time.RadialSelectorView.java
jp.seesaa.android.datetimepicker.time.RadialTextsView.java
jp.seesaa.android.datetimepicker.time.TimePickerDialog.java
jp.seesaa.example.datetimepicker.ApplicationTest.java
jp.seesaa.example.datetimepicker.MainActivity.java