美文网首页
时间选择器

时间选择器

作者: csp | 来源:发表于2017-03-08 15:11 被阅读7次

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();

        }
    });
}

}

相关文章

网友评论

      本文标题:时间选择器

      本文链接:https://www.haomeiwen.com/subject/kfvbgttx.html