tags:

views:

34

answers:

1

Hi,

I'm using hierarchyviewer to look through a widget that I'm using. (TimePicker).

Now I can see that TimePicker contains id/decrement, id/increment and id/timepicker_input.

How do I get a reference to id/timepicker_input for example?

Tried my_picker.findViewWithTag("decrement"); but that returns null.

Thanks, Tee

A: 

I don't see those IDs on the TimePicker layout

http://www.google.com/codesearch/p?hl=en#uX1GffpyOZk/core/res/res/layout/time_picker.xml

I see them on NumberPicker which is used by TimePicker

http://www.google.com/codesearch/p?hl=en#uX1GffpyOZk/core/res/res/layout/number_picker.xml

You would have to locate the appropriate NumberPicker view, then locate the NumberPickerButton view.

However you have two problems here. 1. You can't get at the IDs because they're not exposed (you'd be looking at android.R.id.decrement etc.), and 2. This will be very brittle because the internal implementation of these controls will change.

If your project will have a compatible license to Apache License, Version 2.0, what you can do is to copy all of the TimePicker and NumberPicker layouts and classes into your own project, and customize them there. This way you will have full control and it is much less likely to break with future OSes.

Jim Blackler