时间选择器

2017-03-08  本文已影响7人  csp

public class ChooseTime extends AppCompatActivity {

private Button chooseTime;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_choose_time);

    chooseTime = (Button)findViewById(R.id.btnChooseTime);
    chooseTime.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            new TimePickerDialog(ChooseTime.this, new TimePickerDialog.OnTimeSetListener() {
                @Override
                public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

                    String theTime = String.format("%d:%d",hourOfDay,minute);
                    System.out.println(theTime);
                }
            },0,0,true).show();

        }
    });
}

}

上一篇 下一篇

猜你喜欢

热点阅读