public class Activity1 extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
DatePicker datepicker = (DatePicker) findViewById(R.id.datePicker1);
findAndHideField(datepicker, "mDayPicker");
// findAndHideField(datepicker, "mMonthPicker");
// Honeycomb(+) fields:
findAndHideField(datepicker, "mDaySpinner");
// findAndHideField(datepicker, "mMonthSpinner");
}
/** find a member field by given name and hide it */
private void findAndHideField(DatePicker datepicker, String name) {
try {
Field field = DatePicker.class.getDeclaredField(name);
field.setAccessible(true);
View fieldInstance = (View) field.get(datepicker);
fieldInstance.setVisibility(View.GONE);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
DatePicker datepicker = (DatePicker) findViewById(R.id.datePicker1);
findAndHideField(datepicker, "mDayPicker");
// findAndHideField(datepicker, "mMonthPicker");
// Honeycomb(+) fields:
findAndHideField(datepicker, "mDaySpinner");
// findAndHideField(datepicker, "mMonthSpinner");
}
/** find a member field by given name and hide it */
private void findAndHideField(DatePicker datepicker, String name) {
try {
Field field = DatePicker.class.getDeclaredField(name);
field.setAccessible(true);
View fieldInstance = (View) field.get(datepicker);
fieldInstance.setVisibility(View.GONE);
} catch (Exception e) {
e.printStackTrace();
}
}
}
No comments:
Post a Comment