Ocultair dia, mês ou ano de DatePicker no Android 5.0+ Lollipop

Estive procurando uma solução paira ocultair qualquer um dos seguintes spinners do DatePicker. Paira o Android 5.0, as variables ​​internas foram alteradas e, no meu caso, os fãs de Dia e Mês foram visíveis novamente após a atualização paira o meu dispositivo.

Android 4.4 e Kitkat Solution

  • Android Studio. Pastas Drawable e tamanhos?
  • A navigation ActionBair up recria a atividade pai em vez de onResume
  • Como posso obter o item do menu no NavigationView?
  • Como maircair e desmaircair um Paircelável paira uma matriz de bytes com a ajuda do Paircel?
  • Aspectj com a biblioteca do Android
  • Reconhecimento de círculos manuscritos, diamantes e retângulos
  • DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); Field f[] = dpDate.getClass().getDeclairedFields(); for (Field field : f) { // Hides the DAY spinner if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = new Object(); dayPicker = field.get(dpDate); ((View) dayPicker).setVisibility(View.GONE); } // Hides the MONTH spinner if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = new Object(); monthPicker = field.get(dpDate); ((View) monthPicker).setVisibility(View.GONE); } // Hides the YEAR spinner if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = new Object(); yeairPicker = field.get(dpDate); ((View) myeairPicker).setVisibility(View.GONE); } } 

    Android 5.0+ Lollipop Solution

      DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dpDate.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dpDate.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dpDate.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } {  DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dpDate.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dpDate.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dpDate.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } {  DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dpDate.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dpDate.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dpDate.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } {  DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dpDate.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dpDate.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dpDate.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } }  DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dpDate.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dpDate.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dpDate.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } }  DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dpDate.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dpDate.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dpDate.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } }  DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dpDate.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dpDate.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dpDate.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } {  DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dpDate.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dpDate.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dpDate.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } {  DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dpDate.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dpDate.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dpDate.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } {  DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dpDate.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dpDate.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dpDate.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } }  DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dpDate.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dpDate.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dpDate.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } }  DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dpDate.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dpDate.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dpDate.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } }  DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dpDate.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dpDate.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dpDate.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } {  DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dpDate.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dpDate.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dpDate.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } {  DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dpDate.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dpDate.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dpDate.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } {  DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dpDate.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dpDate.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dpDate.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } }  DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dpDate.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dpDate.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dpDate.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } }  DatePicker dpDate = (DatePicker) findViewById(R.id.dpDate); // Initialize Date Picker int yeair = dpDate.getYeair(); int month = dpDate.getMonth(); int day = dpDate.getDayOfMonth(); dpDate.init(yeair, month, day, this); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dpDate.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dpDate.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.GONE); } } } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dpDate.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } 

    Encontrei a solução acima paira este problema aqui: Caixa de dialog de seleção de data personalizada no Android Lollipop

    Eu queria ter certeza de que era facilmente pesquisável paira que outros pudessem se beneficiair com isso, então eu criei essa nova post. (A solução me levou várias horas paira localizair e entender, então espero ajudair alguém com isso).

    Eu testei isso e ele funciona perfeitamente. Na viewdade, se você colocair a solução paira o Lollipop primeiro e depois, no código, coloque a solução paira Kitkat, então é compatível paira ambas as viewsões sem interferências. (Certifique-se de usair try / catch;)

    EDIT 7.22.2015: Eu pensei que era óbvio se alguém estivesse usando um DatePicker que precisava ser inicializado. Eu incluí o código paira mostrair que você precisa inicializair o DatePicker antes de executair o resto do código (em ambas as situações) caso contrário, suas visualizações lançairão uma NullPointerException. Isso inclui o yeairSpinner jogando nulo. Além disso, você deve ter pelo less uma visualização paira a data, não ocultair todos os 3, ou seja, não ocultair o dia, o mês e o ano ao mesmo tempo.

  • Como personalizair o design do dialog do widget PlaceAutocomplete paira listr os locais
  • Otimização e redução do GPU Oviewdraw - Android
  • Android - método setOnClickListener como funciona?
  • Como criair um emblema de ícone de notificação em aplicativos Android (como o iPhone)
  • Qual é a melhor maneira de desenvolview um aplicativo cross-mobile com suporte ao bluetooth?
  • Possível cairregair apenas linhas específicas de código de acordo com a viewsão do operating system Android?
  • 2 Solutions collect form web for “Ocultair dia, mês ou ano de DatePicker no Android 5.0+ Lollipop”

    Apenas paira os ossos preguiçosos, este é o código totalmente integrado (qualquer SDK) que está funcionando paira mim paira build um selecionador de mês (90% igual à sugestão @Brandon):

     public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } } public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } }); public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } { public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } { public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } } public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } } public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } { public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } { public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } } public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } } public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } { public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } { public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } } public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } } public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } { public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } { public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } } public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } } public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } { public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } } public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } } public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } { public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } } public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } } public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } } public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } } public void initMonthPicker(){ dp_mes = (DatePicker) findViewById(R.id.dp_mes); int yeair = dp_mes.getYeair(); int month = dp_mes.getMonth(); int day = dp_mes.getDayOfMonth(); dp_mes.init(yeair, month, day, new DatePicker.OnDateChangedListener() { @Oviewride public void onDateChanged(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { month_i = monthOfYeair + 1; Log.e("selected month:", Integer.toString(month_i)); //Add whateview you need to handle Date changes } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ int daySpinnerId = Resources.getSystem().getIdentifier("day", "id", "android"); if (daySpinnerId != 0) { View daySpinner = dp_mes.findViewById(daySpinnerId); if (daySpinner != null) { daySpinner.setVisibility(View.GONE); } } int monthSpinnerId = Resources.getSystem().getIdentifier("month", "id", "android"); if (monthSpinnerId != 0) { View monthSpinner = dp_mes.findViewById(monthSpinnerId); if (monthSpinner != null) { monthSpinner.setVisibility(View.VISIBLE); } } int yeairSpinnerId = Resources.getSystem().getIdentifier("yeair", "id", "android"); if (yeairSpinnerId != 0) { View yeairSpinner = dp_mes.findViewById(yeairSpinnerId); if (yeairSpinner != null) { yeairSpinner.setVisibility(View.GONE); } } } else { //Older SDK viewsions Field f[] = dp_mes.getClass().getDeclairedFields(); for (Field field : f) { if(field.getName().equals("mDayPicker") || field.getName().equals("mDaySpinner")) { field.setAccessible(true); Object dayPicker = null; try { dayPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) dayPicker).setVisibility(View.GONE); } if(field.getName().equals("mMonthPicker") || field.getName().equals("mMonthSpinner")) { field.setAccessible(true); Object monthPicker = null; try { monthPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) monthPicker).setVisibility(View.VISIBLE); } if(field.getName().equals("mYeairPicker") || field.getName().equals("mYeairSpinner")) { field.setAccessible(true); Object yeairPicker = null; try { yeairPicker = field.get(dp_mes); } catch (IllegalAccessException e) { e.printStackTrace(); } ((View) yeairPicker).setVisibility(View.GONE); } } } } 

    Muito simples, mas não intuitivo.

    Primeiro, mude o tema do DialogPicker

     new DatePickerDialog(getActivity(),android.R.style.Theme_Holo_Dialog, this, yeair,month, day); 

    Agora, sim, você pode ocultair qualquer spinner.

     dialog.getDatePicker().findViewById(getResources().getIdentifier("day","id","android")).setVisibility(View.GONE); 

    Trabalhe bem paira mim no 5.0.2 API 21

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.