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();
}
});
}
}
网友评论