FileDocCategorySizeDatePackage
DateWidgets2.javaAPI DocAndroid 1.5 API2036Wed May 06 22:41:08 BST 2009com.example.android.apis.view

DateWidgets2

public class DateWidgets2 extends android.app.Activity

Fields Summary
private android.widget.TextView
mTimeDisplay
Constructors Summary
Methods Summary
protected voidonCreate(android.os.Bundle savedInstanceState)

        super.onCreate(savedInstanceState);

        setContentView(R.layout.date_widgets_example_2);

        TimePicker timePicker = (TimePicker) findViewById(R.id.timePicker);
        timePicker.setCurrentHour(12);
        timePicker.setCurrentMinute(15);

        mTimeDisplay = (TextView) findViewById(R.id.dateDisplay);

        updateDisplay(12, 15);

        timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {

            public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
                updateDisplay(hourOfDay, minute);
            }
        });
    
private static java.lang.Stringpad(int c)

        if (c >= 10)
            return String.valueOf(c);
        else
            return "0" + String.valueOf(c);
    
private voidupdateDisplay(int hourOfDay, int minute)

        mTimeDisplay.setText(
                    new StringBuilder()
                    .append(pad(hourOfDay)).append(":")
                    .append(pad(minute)));