Search in sources :

Example 6 with DatePickerBuilder

use of com.codetroopers.betterpickers.datepicker.DatePickerBuilder in project android-betterpickers by code-troopers.

the class SampleDateMultipleHandlers method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.text_and_button);
    mResultTextView = (TextView) findViewById(R.id.text);
    Button button = (Button) findViewById(R.id.button);
    mResultTextView.setText(R.string.no_value);
    button.setText(R.string.date_picker_set);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DatePickerBuilder dpb = new DatePickerBuilder().setFragmentManager(getSupportFragmentManager()).setStyleResId(R.style.BetterPickersDialogFragment).addDatePickerDialogHandler(new MyCustomHandler());
            dpb.show();
        }
    });
}
Also used : Button(android.widget.Button) DatePickerBuilder(com.codetroopers.betterpickers.datepicker.DatePickerBuilder) TextView(android.widget.TextView) View(android.view.View)

Example 7 with DatePickerBuilder

use of com.codetroopers.betterpickers.datepicker.DatePickerBuilder in project android-betterpickers by code-troopers.

the class SampleDatePreset method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.date_preset);
    mResultTextView = (TextView) findViewById(R.id.text);
    Button button = (Button) findViewById(R.id.button);
    month = (EditText) findViewById(R.id.month);
    date = (EditText) findViewById(R.id.date);
    year = (EditText) findViewById(R.id.year);
    mResultTextView.setText(R.string.no_value);
    button.setText(R.string.date_picker_set);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            int m = -1;
            int d = -1;
            int y = -1;
            try {
                m = Integer.parseInt(month.getText().toString());
            } catch (Exception e) {
                m = -1;
            }
            try {
                d = Integer.parseInt(date.getText().toString());
            } catch (Exception e) {
                d = -1;
            }
            try {
                y = Integer.parseInt(year.getText().toString());
            } catch (Exception e) {
                y = -1;
            }
            DatePickerBuilder dpb = new DatePickerBuilder().setFragmentManager(getSupportFragmentManager()).setStyleResId(R.style.BetterPickersDialogFragment).setMonthOfYear(m).setDayOfMonth(d).setYear(y);
            dpb.show();
        }
    });
}
Also used : Button(android.widget.Button) DatePickerBuilder(com.codetroopers.betterpickers.datepicker.DatePickerBuilder) TextView(android.widget.TextView) View(android.view.View)

Example 8 with DatePickerBuilder

use of com.codetroopers.betterpickers.datepicker.DatePickerBuilder in project android-betterpickers by code-troopers.

the class SampleDatePresetLight method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.date_preset);
    text = (TextView) findViewById(R.id.text);
    Button button = (Button) findViewById(R.id.button);
    month = (EditText) findViewById(R.id.month);
    date = (EditText) findViewById(R.id.date);
    year = (EditText) findViewById(R.id.year);
    text.setText(R.string.no_value);
    button.setText(R.string.date_picker_set);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            int m = -1;
            int d = -1;
            int y = -1;
            try {
                m = Integer.parseInt(month.getText().toString());
            } catch (Exception e) {
                m = -1;
            }
            try {
                d = Integer.parseInt(date.getText().toString());
            } catch (Exception e) {
                d = -1;
            }
            try {
                y = Integer.parseInt(year.getText().toString());
            } catch (Exception e) {
                y = -1;
            }
            DatePickerBuilder dpb = new DatePickerBuilder().setFragmentManager(getSupportFragmentManager()).setStyleResId(R.style.BetterPickersDialogFragment_Light).setMonthOfYear(m).setDayOfMonth(d).setYear(y);
            dpb.show();
        }
    });
}
Also used : Button(android.widget.Button) DatePickerBuilder(com.codetroopers.betterpickers.datepicker.DatePickerBuilder) TextView(android.widget.TextView) View(android.view.View)

Example 9 with DatePickerBuilder

use of com.codetroopers.betterpickers.datepicker.DatePickerBuilder in project android-betterpickers by code-troopers.

the class SampleDateFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.text_and_button, container, false);
    mResultTextView = (TextView) view.findViewById(R.id.text);
    Button button = (Button) view.findViewById(R.id.button);
    mResultTextView.setText(R.string.no_value);
    button.setText(R.string.date_picker_set);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DatePickerBuilder dpb = new DatePickerBuilder().setFragmentManager(getChildFragmentManager()).setStyleResId(R.style.BetterPickersDialogFragment).setTargetFragment(SampleDateFragment.this);
            dpb.show();
        }
    });
    return view;
}
Also used : Button(android.widget.Button) DatePickerBuilder(com.codetroopers.betterpickers.datepicker.DatePickerBuilder) TextView(android.widget.TextView) View(android.view.View)

Aggregations

View (android.view.View)9 Button (android.widget.Button)9 TextView (android.widget.TextView)9 DatePickerBuilder (com.codetroopers.betterpickers.datepicker.DatePickerBuilder)9