public class TimePickerActivity extends AppCompatActivity {
TimePicker timePicker;
Button button;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_time_picker);
timePicker=(TimePicker)findViewById(R.id.timePicker);
button=(Button)findViewById(R.id.button4);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String currtTime=timePicker.getCurrentHour()+"--"+timePicker.getCurrentMinute();
Toast.makeText(getApplicationContext(),currtTime,Toast.LENGTH_SHORT).show();
}
});
}
}
No comments:
Post a Comment