Posts CiTuX - datetimepicker
Post
Cancel

CiTuX - datetimepicker

https://github.com/CiTuX/datetimepicker

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
public class MainActivity extends Activity implements OnDateSetListener, OnTimeSetListener {

    private Calendar calendar;
    private static final String TIME_PATTERN = "HH:mm";

    private Button btn_date;

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

		btn_no = (Button)	findViewById(R.id.btn_no);
		btn_date = (Button)	findViewById(R.id.btn_dt);
		btn_cost= (Button)	findViewById(R.id.btn_cost);

	  calendar = Calendar.getInstance();
	    dateFormat = DateFormat.getDateInstance(DateFormat.LONG, Locale.getDefault());
	    timeFormat = new SimpleDateFormat(TIME_PATTERN, Locale.getDefault());
	}

    @Override
    public void onDateSet(DatePickerDialog dialog, int year, int monthOfYear, int dayOfMonth) {
        calendar.set(year, monthOfYear, dayOfMonth);

        //when date selected - call timepicker
        TimePickerDialog.newInstance(this, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), true).show(getFragmentManager(), "timePicker");
        update();
    }

    @Override
    public void onTimeSet(RadialPickerLayout view, int hourOfDay, int minute) {
        calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
        calendar.set(Calendar.MINUTE, minute);

        //format 
        SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmm",Locale.US);
        btn_date.setText(sdf.format(calendar.getTime()));
    }
}

Snap174

origin - http://www.pipiscrew.com/?p=1511 android-citux-datetimepicker

This post is licensed under CC BY 4.0 by the author.
Contents

Trending Tags