RuAware
RuAware

Reputation: 969

Time picker 4.2 and getting Edit Text

i've been using upto 4.1.......

TimePicker tpClock = (TimePicker) findViewById(R.id.tpClock);
View view  = tpClock.getChildAt(0);
EditText etHours = (EditText) ((ViewGroup)((ViewGroup) view).getChildAt(0)).getChildAt(1);

this gets the Hour edittext so I can hide it.

This has been working really well

However it is not working for 4.2. How do I find what they have changed?

Thanks

Upvotes: 1

Views: 681

Answers (2)

Anatolii
Anatolii

Reputation: 66

Try this:

TimePicker view = new TimePicker(this);
View hour = view.findViewById(Resources.getSystem().getIdentifier("hour", "id", "android"));
View input = hour.findViewById(Resources.getSystem().getIdentifier("numberpicker_input", "id", "android"));
// then you can do this
input.setClickable(false);
input.setFocusable(false);
// or this
input.setVisibility(View.GONE);

Upvotes: 2

Related Questions