Last active
August 29, 2015 14:10
-
-
Save jclehner/e10ba5d4e46a094549f6 to your computer and use it in GitHub Desktop.
TimePickerTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical"> | |
<TimePicker android:id="@+id/picker" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:timePickerMode="clock" | |
/> | |
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.timepickertest; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.text.format.DateFormat; | |
import android.widget.TimePicker; | |
import android.widget.TimePicker.OnTimeChangedListener; | |
import android.widget.Toast; | |
public class MainActivity extends Activity implements OnTimeChangedListener | |
{ | |
private TimePicker mPicker; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) | |
{ | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
mPicker = (TimePicker) findViewById(R.id.picker); | |
mPicker.setIs24HourView(DateFormat.is24HourFormat(this)); | |
mPicker.setOnTimeChangedListener(this); | |
} | |
@Override | |
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) | |
{ | |
// These toasts never happen when timePickerMode="clock"! | |
Toast.makeText(this, "onTimeChanged:\nh=" + hourOfDay + ", m=" + minute, Toast.LENGTH_SHORT).show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment