android DatePickerDialog怎么设置日期选择范围
展开全部
package com.solide;
import java.util.Calendar;
import android.app.Activity;
import android.app.TimePickerDialog;
import android.app.TimePickerDialog.OnTimeSetListener;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TimePicker;
public class TestTimeTickerActivity extends Activity implements OnClickListener{
/** Called when the activity is first created. */
private Calendar c;
private Button button;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button)findViewById(R.id.button);
button.setOnClickListener(this);
c = Calendar.getInstance();
c.setTimeInMillis(System.currentTimeMillis());
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
new TimePickerDialog(this, new OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
// TODO Auto-generated method stub
}
}
, hour, minute, DateFormat.is24HourFormat(this)).show();
}
}
去试试
import java.util.Calendar;
import android.app.Activity;
import android.app.TimePickerDialog;
import android.app.TimePickerDialog.OnTimeSetListener;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TimePicker;
public class TestTimeTickerActivity extends Activity implements OnClickListener{
/** Called when the activity is first created. */
private Calendar c;
private Button button;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button)findViewById(R.id.button);
button.setOnClickListener(this);
c = Calendar.getInstance();
c.setTimeInMillis(System.currentTimeMillis());
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
new TimePickerDialog(this, new OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
// TODO Auto-generated method stub
}
}
, hour, minute, DateFormat.is24HourFormat(this)).show();
}
}
去试试
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询