使用このコード:
package org.stellent.Sample;
import java.util.Calendar;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.TimePickerDialog;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TimePicker;
public class DateandTime extends Activity implements OnClickListener{
private static final int TIME_DIALOG = 1;
Button time;
public void onCreate(Bundle state){
super.onCreate(state);
setContentView(R.layout.timeanddate);
time=(Button)findViewById(R.id.time);
time.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if(v.equals(time)){
showDialog(TIME_DIALOG);
}
}
public Dialog onCreateDialog(int id){
Calendar cal=Calendar.getInstance();
switch(id){
case TIME_DIALOG:
return new TimePickerDialog(this,timepicker,cal.get(Calendar.HOUR_OF_DAY),cal.get(Calendar.MINUTE), false);
}
return null;
}
TimePickerDialog.OnTimeSetListener timepicker=new TimePickerDialog.OnTimeSetListener(){
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
Log.e("time :",String.valueOf(hourOfDay)+" : "+String.valueOf(minute));
}
};
}
あなたのコードを投稿してください。 – kaspermoerch