本文整理汇总了Java中android.widget.TimePicker.setIs24HourView方法的典型用法代码示例。如果您正苦于以下问题:Java TimePicker.setIs24HourView方法的具体用法?Java TimePicker.setIs24HourView怎么用?Java TimePicker.setIs24HourView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TimePicker
的用法示例。
在下文中一共展示了TimePicker.setIs24HourView方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.widget.TimePicker; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notificacoes);
setTitle("Notificações");
timePicker = (TimePicker) findViewById(R.id.timePicker);
timePicker.setIs24HourView(true);
findViewById(R.id.setAlarmButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
h = timePicker.getCurrentHour();
m = timePicker.getCurrentMinute();
startAlarm();
}
});
findViewById(R.id.cancelAlarm).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
cancelAlarm();
}
});
}
示例2: onCreate
import android.widget.TimePicker; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_time_selection);
Bundle extras = getIntent().getExtras();
setTitle(extras.getInt("title"));
//noinspection ConstantConditions
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(this, extras.getInt("color"))));
dtpTime = (TimePicker) findViewById(R.id.timePicker);
dtpTime.setIs24HourView(true);
timeSelection = GregorianCalendar.getInstance();
timeSelection.setTimeInMillis(extras.getLong("date"));
//noinspection deprecation
dtpTime.setCurrentHour(timeSelection.get(Calendar.HOUR_OF_DAY));
//noinspection deprecation
dtpTime.setCurrentMinute(timeSelection.get(Calendar.MINUTE));
}
示例3: onCreateDialogView
import android.widget.TimePicker; //导入方法依赖的package包/类
@Override
protected View onCreateDialogView() {
TimePicker tp = new TimePicker(getContext());
tp.setIs24HourView(DateFormat.is24HourFormat(getContext()));
tp.setOnTimeChangedListener(this);
originalHour = getHour();
originalMinute = getMinute();
if (originalHour >= 0 && originalMinute >= 0) {
tp.setCurrentHour(originalHour);
tp.setCurrentMinute(originalMinute);
}
return tp;
}
示例4: pickTime
import android.widget.TimePicker; //导入方法依赖的package包/类
/**
* 时间选择对话框
*
* @param con 上下文
* @param title 标题
* @param listener 选择事件
* @param cal 默认时间
*/
public static void pickTime(Context con, String title, Calendar cal, final OnTimeSetListener listener) {
LinearLayout ll = new LinearLayout(con);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
ll.setLayoutParams(layoutParams);
ll.setOrientation(LinearLayout.VERTICAL);
//添加一条线
LinearLayout line = new LinearLayout(con);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1);
line.setBackgroundColor(con.getResources().getColor(R.color.line));
line.setLayoutParams(lp);
ll.addView(line);
//添加选择器控件
final TimePicker timePicker = new TimePicker(con, null, themeId);
timePicker.setLayoutParams(layoutParams);
timePicker.setCurrentHour(cal.get(Calendar.HOUR_OF_DAY));
timePicker.setCurrentMinute(cal.get(Calendar.MINUTE));
timePicker.setIs24HourView(true);
ll.addView(timePicker);
QuickDialog.Builder builder = new QuickDialog.Builder(con);
builder.setContentView(ll);
builder.setTitle(title);
builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
listener.onTimeSet(timePicker, timePicker.getCurrentHour(), timePicker.getCurrentMinute());
}
});
builder.create().show();
}
示例5: init
import android.widget.TimePicker; //导入方法依赖的package包/类
private void init(){
startTime = (TimePicker) findViewById(R.id.start_time);
endTime = (TimePicker) findViewById(R.id.end_time);
startTime.setIs24HourView(DateFormat.is24HourFormat(this));
endTime.setIs24HourView(DateFormat.is24HourFormat(this));
mSetTime = (Button)findViewById(R.id.bu_setTime);
mMonday = (CheckBox)findViewById(R.id.cb_monday);
mTuesday = (CheckBox)findViewById(R.id.cb_tuesday);
mWednesday = (CheckBox)findViewById(R.id.cb_wednesday);
mThursday = (CheckBox)findViewById(R.id.cb_thursday);
mFriday = (CheckBox)findViewById(R.id.cb_friday);
mSaturday = (CheckBox)findViewById(R.id.cb_saturday);
mSunday = (CheckBox)findViewById(R.id.cb_sunday);
}
示例6: onCreateContentView
import android.widget.TimePicker; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
protected View onCreateContentView(Bundle savedInstanceState) {
picker = new TimePicker(getContext());
if (savedInstanceState != null){
picker.setCurrentHour(savedInstanceState.getInt(HOUR));
picker.setCurrentMinute(savedInstanceState.getInt(MINUTE));
} else {
if (getArguments().containsKey(HOUR)) {
picker.setCurrentHour(getArguments().getInt(HOUR));
}
if (getArguments().containsKey(MINUTE)) {
picker.setCurrentMinute(getArguments().getInt(MINUTE));
}
}
if (getArguments().containsKey(VIEW_24_HOUR)) {
picker.setIs24HourView(getArguments().getBoolean(VIEW_24_HOUR));
} else {
picker.setIs24HourView(DateFormat.is24HourFormat(getContext())); // system default
}
picker.setOnTimeChangedListener(this);
return picker;
}
示例7: onCreateDialogView
import android.widget.TimePicker; //导入方法依赖的package包/类
@Override
protected View onCreateDialogView() {
Context context = getContext();
TimePicker timePicker = new TimePicker(context);
timePicker.setIs24HourView(is24HourFormat(context));
timePicker.setOnTimeChangedListener(this);
timePicker.setCurrentHour(getHour());
timePicker.setCurrentMinute(getMinute());
return timePicker;
}
示例8: TimePreference
import android.widget.TimePicker; //导入方法依赖的package包/类
public TimePreference(Context context, AttributeSet attrs, int defStyleAttr){
super(context, attrs, defStyleAttr);
timePicker = new TimePicker(context);
timePicker.setId(View.generateViewId());
timePicker.setEnabled(true);
timePicker.setIs24HourView(true);
setDialogIcon(null);
setPositiveButtonText(android.R.string.ok);
setNegativeButtonText(android.R.string.cancel);
}
示例9: onCreateDialogView
import android.widget.TimePicker; //导入方法依赖的package包/类
@Override
protected View onCreateDialogView() {
mPicker = new TimePicker(getContext());
mPicker.setIs24HourView(mTimerMode || DateFormat.is24HourFormat(getContext()));
return mPicker;
}
示例10: onViewCreated
import android.widget.TimePicker; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
TimePicker timePicker = (TimePicker) view.findViewById(R.id.feature_time_picker);
timePicker.setIs24HourView(true);
}
示例11: onCreateDialogView
import android.widget.TimePicker; //导入方法依赖的package包/类
@Override
protected View onCreateDialogView() {
picker = new TimePicker(getContext());
picker.setIs24HourView(true);
return (picker);
}