2013-05-07 56 views
1

我一直在使用高達4.1 .......時間選擇器4.2和獲得編輯文本

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

這得到了一小時的EditText,所以我可以將其隱藏。

這一直工作得很好

但是它不是爲4.2工作。我如何找到他們已經改變的東西?

感謝

回答

1

試試這個:

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); 
相關問題