最佳答案
将复选框监听器设置为您需要查看复选框
原文链接:https://www.f2er.com/android/430269.htmlif(id == R.id.event_checkBox_year)
{
if(ch.isChecked())
{
visiblity = View.GONE;
}
else
{
visiblity = View.VISIBLE;
}
showHideYear(visiblity);
}
private void showHideYear(int visiblity)
{
try {
Field f[] = date.getClass().getDeclaredFields();
for (Field field : f) {
if (field.getName().equals("mYearSpinner") ||field.getName().equals("mYearPicker") )
{
field.setAccessible(true);
Object yearPicker = new Object();
yearPicker = field.get(date);
((View) yearPicker).setVisibility(visiblity);
}
}
} catch (SecurityException e)
{
Log.d("ERROR",e.getMessage());
}
catch (IllegalArgumentException e)
{
Log.d("ERROR",e.getMessage());
} catch (IllegalAccessException e)
{
Log.d("ERROR",e.getMessage());
}
}