Mike James
Mike James

Reputation: 799

Android Studio 3.1 Where is the TimePicker in the Layout Editor

On upgrade to Android Studio 3.1 there is no TimePicker in the layout editor palette.
Search doesn't find it.
In fact all of the picker controls seem to have vanished. They were there in 3.0.

Upvotes: 18

Views: 8727

Answers (3)

aaroncio
aaroncio

Reputation: 307

As stated in the other answers, there is comment in the release notes about the improvements in the palette.

https://developer.android.com/studio/releases/index.html#layout_editor

For some unknown reason the @Widget annotation cannot be located in the project. Android annotation package TimePicker class

A dirty trick I made, is to create my own @Widget annotation copying their code and then add it to a custom class which inherits from TimePicker, of course this is just if you are eager to have it in the Palette of your project xD

example: Widget.java

package com.example.ctuser1.myapplication;

import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.SOURCE)
public @interface Widget {
}

MyTimePicker.java

package com.example.ctuser1.myapplication;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TimePicker;

@Widget
public class MyTimePicker extends TimePicker {
  public MyTimePicker(Context context) {
      super(context);
  }

  public MyTimePicker(Context context, AttributeSet attrs) {
      super(context, attrs);
  }

  public MyTimePicker(Context context, AttributeSet attrs, int defStyleAttr) {
      super(context, attrs, defStyleAttr);
  }

}

Result:

Result in design Palette

Upvotes: 2

Jade
Jade

Reputation: 3244

The Android Studio 3.1 release notes state that

Palette in the Layout Editor has received many improvements

It also states that there was

Reorganization of categories for views and layouts.

So changes to this section were planned for this release. This makes me speculate that removal of the pickers is purposeful.

This reorganization of the palette was noticed prior to final release of Android Studio 3.1 and a bug was filed. Although the bug was assigned no comment was added.

One of the bugs submitted for this issue has been assigned to a Googler. Again this isn't an official sign either way.

Upvotes: 1

luckyging3r
luckyging3r

Reputation: 3165

I am not sure where to find it in the selection menu but if you just need a time picker in your project you can select the Text tab on the bottom of your activity.xml file and paste the TimePicker xml.

<TimePicker
android:id="@+id/simpleTimePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:timePickerMode="spinner"/>

Then you can select which timePickerMode you want if you want a clock then change spinner with clock.

Hope this helps.

Upvotes: 6

Related Questions