com.doomonafireball.betterpickers.sample.activity.datepicker.SampleDateDefault Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sample Show documentation
Show all versions of sample Show documentation
Android library for better number/date/time-picker DialogFragments.
package com.doomonafireball.betterpickers.sample.activity.datepicker;
import com.doomonafireball.betterpickers.datepicker.DatePickerBuilder;
import com.doomonafireball.betterpickers.datepicker.DatePickerDialogFragment;
import com.doomonafireball.betterpickers.sample.R;
import com.doomonafireball.betterpickers.sample.activity.BaseSampleActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
/**
* User: derek Date: 3/17/13 Time: 3:59 PM
*/
public class SampleDateDefault extends BaseSampleActivity implements DatePickerDialogFragment.DatePickerDialogHandler {
private TextView text;
private Button button;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.text_and_button);
text = (TextView) findViewById(R.id.text);
button = (Button) findViewById(R.id.button);
text.setText("--");
button.setText("Set Date");
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DatePickerBuilder dpb = new DatePickerBuilder()
.setFragmentManager(getSupportFragmentManager())
.setStyleResId(R.style.BetterPickersDialogFragment);
dpb.show();
}
});
}
@Override
public void onDialogDateSet(int reference, int year, int monthOfYear, int dayOfMonth) {
text.setText("Year: " + year + "\nMonth: " + monthOfYear + "\nDay: " + dayOfMonth);
}
}