0

I'm trying to extend android's DatePicker.

My first attempt involved extending the class directly. i.e.

public class CustomDatePicker extends DatePicker{
...

however many of the useful methods inside DatePicker are declared private. Especially the "updateSpinners()" which is where most of the work is done. Adding any significant functionality to the component by using extends looks to be very difficult.

My next attempt was to copy the code directly from DatePicker into my own class, CustomDatePicker.

However the problem I'm now getting is that the code references id's inside the NumberPicker layout.

e.g.

mDaySpinnerInput = (EditText) mDaySpinner.findViewById(R.id.numberpicker_input);

The "numberpicker_input" cannot be found in my R class. (Also does not work if I prefix with "android.")

I started to try and copy past the NumberPicker layout files, but then they referenced other resources that did not exist in my project. It felt like I was traveling down a slippery slope!

Is there a way of referencing these id's inside NumberPicker's layout? Is there something I'm missing?

David Smith
  • 38,044
  • 11
  • 44
  • 61
Ben
  • 6,567
  • 10
  • 42
  • 64
  • what exactly are you trying to do here? – tyczj Dec 16 '13 at 19:35
  • I'm trying to customize the text used to display the day component of the date. I wish to have it prefixed with the day-of-the-week. e.g. "Tue 6", rather than just "6". The only other solution I've seen out there http://code.google.com/p/android-wheel/ is not really what I want. – Ben Dec 16 '13 at 19:49
  • you can take the source code and customizes it to your needs: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/1.5_r4/android/widget/DatePicker.java – Goran Horia Mihail Dec 18 '13 at 21:45
  • That was what I did when mentioning: "My next attempt was to copy the code directly from DatePicker into my own class, CustomDatePicker.", but the dependencies on NumberPickers internals was too great. – Ben Dec 20 '13 at 06:23

0 Answers0