<TimePicker
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tp_time"
android:timePickerMode="spinner"
/>
timePicker = findViewById(R.id.tp_time);
//设置为24小时制
timePicker.setIs24HourView(true);
timePicker.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String desc = String.format("你选择的时间是%d时、%d分:",timePicker.getHour(),timePicker.getMinute());
textView.setText(desc);
}
});
标签:xml,String,timePicker,时间,View,选择器,desc
From: https://www.cnblogs.com/loulan/p/16975850.html