Date Picker edition of fields
Is it possible to disable the edition of fields in DatePicker
? Indeed when I touch on the editable box in the DatePicker
, the keyboard
appears, and 开发者_开发问答I don't want this.
Someone have an idea?
Thanks a lot for your response :)
This is actually really easy. Just use
datePicker.setDescendantFocusability(DatePicker.FOCUS_BLOCK_DESCENDANTS);
The NumberPickers will never receive the focus when they are tapped and the soft input keyboard should not appear. I have been using this method on API level 7 with success.
Yeh i got the answer..the thing we need to do is...
DatePicker m_dtPicker = (DatePicker) findViewById(R.id.dt_picker);
setDisabledTextViews(m_dtPicker);
private void setDisabledTextViews(ViewGroup dp)
{
for (int x = 0, n = dp.getChildCount(); x < n; x++)
{
View v = dp.getChildAt(x);
if (v instanceof TextView)
{
v.setEnabled(false);
}
else if (v instanceof ViewGroup)
{
setDisabledTextViews((ViewGroup)v);
}
}
}
This should not be done. DatePicker has that functionality specifically to allow users convenient option instead of tapping/holding +/-
What you are trying to achieve is the iOS for of Picker which although looks nice but really is inconvenient on Android.
精彩评论