This kind of bug is like a black magic :
I am trying to port https://github.com/SimonVT/android-timepicker to complete Holo style (by default it has got only ICS timepicker widget, dialog remains pre-Honeycomb).
I have extended Theme.Sherlock with timepicker’s special attributes , then applied it to whole application. Dialog looks the same as in default ( mentioned above). After that I just added HoloEverywhere lib to project … BLACK magic appears! Timepicker widget somehow lost some of it’s views like blue lines and changed position within dialog. I am still wondering about reason of this glitch.
Note : in my project(code) as well as in TimePicker lib I have got absolutely nothing concerning HoloEverywhere
Note: I also changed some attributes in timepicker because they are conflicting with HoloEverywhere’s attributes (because of “… attribute has already been declared” error)
Code:
public class DialogSample extends SherlockFragmentActivity implements OnTimeSetListener {
private TextView mTimeDisplay;
private int mHour;
private int mMinute;
static final int TIME_DIALOG_ID = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dialog);
final Calendar c = Calendar.getInstance();
mHour = c.get(Calendar.HOUR_OF_DAY);
mMinute = c.get(Calendar.MINUTE);
mTimeDisplay = (TextView) findViewById(R.id.timeDisplay);
findViewById(R.id.btnDialog).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
DialogFragment newFragment = new TimePickerFragment();
newFragment.show(getSupportFragmentManager(), "timePicker");
}
});
updateDisplay();
}
// updates the time we display in the TextView
private void updateDisplay() {
mTimeDisplay.setText(
new StringBuilder()
.append(pad(mHour)).append(":")
.append(pad(mMinute)));
}
private static String pad(int c) {
if (c >= 10) {
return String.valueOf(c);
} else {
return "0" + String.valueOf(c);
}
}
static public class TimePickerFragment extends SherlockDialogFragment {
@Override
public TimePickerDialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
return new TimePickerDialog(getSherlockActivity(), (DialogSample)getSherlockActivity(), hour, minute, true);
}
public TimePickerFragment() {
}
}
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
mHour = hourOfDay;
mMinute = minute;
updateDisplay();
}
}
Solution is tricky : I added HoloEverywhere to
1) NumberPicker lib
2) TimePicker lib
3) TimePicker dialog lib
4) to my project
but I am still not satisfied with this because solution is the same way unclear as an issue