List of usage examples for android.widget TimePicker setDescendantFocusability
public void setDescendantFocusability(int focusability)
From source file:com.simplaapliko.wakeup.sample.ui.DialogDateTime.java
private void initUiWidgets(View rootView) { Log.d(TAG, "initUiWidgets()"); // set up tabhost TabHost tabHost = (TabHost) rootView.findViewById(R.id.tabhost); tabHost.setup();//ww w . j av a 2s .co m TabHost.TabSpec tabSpec; // adding tabs tabSpec = tabHost.newTabSpec("date"); tabSpec.setIndicator("Date"); tabSpec.setContent(R.id.date); tabHost.addTab(tabSpec); tabSpec = tabHost.newTabSpec("time"); tabSpec.setIndicator("Time"); tabSpec.setContent(R.id.time); tabHost.addTab(tabSpec); TimePicker timePicker = (TimePicker) rootView.findViewById(R.id.time); timePicker.setIs24HourView(true); //set to true, because it is more compact timePicker.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); // init time picker before OnTimeChangedListener() is set // otherwise minutes will be set to current time, once setCurrentHour() is called timePicker.setCurrentHour(mCalendar.get(Calendar.HOUR_OF_DAY)); timePicker.setCurrentMinute(mCalendar.get(Calendar.MINUTE)); timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() { @Override public void onTimeChanged(TimePicker view, int hourOfDay, int minute) { mCalendar.set(Calendar.HOUR_OF_DAY, hourOfDay); mCalendar.set(Calendar.MINUTE, minute); mCalendar.set(Calendar.SECOND, 0); } }); DatePicker datePicker = (DatePicker) rootView.findViewById(R.id.date); datePicker.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); datePicker.init(mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH), new DatePicker.OnDateChangedListener() { @Override public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) { mCalendar.set(Calendar.YEAR, year); mCalendar.set(Calendar.MONTH, monthOfYear); mCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); } }); }