1

I'm trying to use a TimePicker to get a time from the user but for some reason the xml won't render in the design screen and I'm given this error:

Couldn't resolve resource @layout/time_header_label Failed to parse file /Users/Jake/Library/Android/sdk/platforms/android-21/data/res/layout/time_picker_holo.xml

Has anyone else ran into this? Any ideas? I've checked and made sure that all of my build tools were up to date and even downloaded SDK 20 and 19. Also I have gone to the directory that it references time_picker_holo.xml is indeed there.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="true" >

<!--
        <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".AlarmDetailsActivity" >
-->

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="16dp"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:paddingTop="16dp"
    tools:context=".AlarmDetailsActivity" >

    <TimePicker
        android:id="@+id/alarm_details_time_picker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />



    <EditText
        android:id="@+id/alarm_details_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/alarm_details_time_picker"
        android:layout_marginBottom="@dimen/activity_vertical_margin"
        android:layout_marginTop="@dimen/activity_vertical_margin"
        android:ems="10"
        android:hint="@string/details_alarm_name" />

    <View
        android:id="@+id/divider2"
        style="@style/Divider"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/alarm_details_name" />
    <Switch
        android:id="@+id/alarm_details_repeat_weekly"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/divider2"
        android:text="Repeat Weekly"/>

    <View
        android:id="@+id/divider1"
        style="@style/Divider"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/alarm_details_repeat_weekly" />

    <Switch
        android:id="@+id/alarm_details_repeat_sunday"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/divider1"
        android:text="@string/details_sunday"/>

    <Switch
        android:id="@+id/alarm_details_repeat_monday"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/alarm_details_repeat_sunday"
        android:text="@string/details_monday"/>


    <Switch
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/alarm_details_repeat_tuesday"
        android:layout_alignParentLeft="true"
        android:layout_alignRight="@+id/alarm_details_repeat_monday"
        android:layout_below="@+id/alarm_details_repeat_monday"
        android:checked="true"
        android:text="@string/details_tuesday"
        />


    <Switch
        android:id="@+id/alarm_details_repeat_wednesday"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignRight="@+id/alarm_details_repeat_tuesday"
        android:layout_below="@+id/alarm_details_repeat_tuesday"
        android:checked="true"
        android:text="@string/details_wednesday"

        />

    <Switch
        android:id="@+id/alarm_details_repeat_thursday"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignRight="@+id/alarm_details_repeat_wednesday"
        android:layout_below="@+id/alarm_details_repeat_wednesday"
        android:checked="true"
        android:text="@string/details_thursday"/>

    <Switch
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/alarm_details_repeat_friday"
        android:layout_alignParentLeft="true"
        android:layout_alignRight="@+id/alarm_details_repeat_thursday"
        android:layout_below="@+id/alarm_details_repeat_thursday"
        android:checked="true"
        android:text="@string/details_friday"
        />

    <Switch
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/alarm_details_repeat_saturday"
        android:layout_alignParentLeft="true"
        android:layout_alignRight="@+id/alarm_details_repeat_friday"
        android:layout_below="@+id/alarm_details_repeat_friday"
        android:checked="true"
        android:text="@string/details_saturday"
        />

    <View
        android:id="@+id/divider4"
        style="@style/Divider"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/alarm_details_repeat_saturday" />

    <LinearLayout
        android:id="@+id/alarm_ringtone_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/divider4"
        android:background="@drawable/view_touch_selector"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/alarm_label_tone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/activity_vertical_margin"
            android:text="@string/details_alarm_tone"
            android:textSize="18sp" />

        <TextView
            android:id="@+id/alarm_label_tone_selection"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/activity_vertical_margin"
            android:text="@string/details_alarm_tone_default"
            android:textSize="14sp" />
    </LinearLayout>

    <View
        android:id="@+id/divider3"
        style="@style/Divider"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/alarm_ringtone_container" />
</RelativeLayout>

Jake Siel
  • 11
  • 3
  • There is something wrong with "@layout/time_header_label". Is this a layout? Can you post it? Judging from the name it's supposed to be a string in "@string" not "@layout" – VERT9x Mar 06 '15 at 18:43
  • No, this is not a layout, it's just an xml file that is packaged with the SDK. I edited the post to include the layout. – Jake Siel Mar 06 '15 at 19:00
  • "@layout/time_header_label" is being referenced somewhere and can't be found. Can you find where it's being referenced? – VERT9x Mar 06 '15 at 19:07
  • Ya, that's what I'm so confused about. I searched throughout my entire project and it's nowhere to be found. My only guess is that it is intrinsically referenced when you use a TimePicker? – Jake Siel Mar 06 '15 at 19:09
  • Was this a compile error or runtime error? Can you post the stacktrace? Can you post the java code where you load the layouts? – VERT9x Mar 06 '15 at 19:14
  • It's not really a compile error or runtime error, it just won't appear in the design screen. It actually does run and compile. Thanks for your time by the way. I appreciate it. – Jake Siel Mar 06 '15 at 19:24
  • What design screen? In your IDE? What IDE are you using? – VERT9x Mar 06 '15 at 19:33
  • I'm using Android Studio. By design screen I mean how in xml you can either be in the Design or Text screen. It's not an enormous deal because I guess I can see the layout in my app. It's just a little annoying I suppose. – Jake Siel Mar 06 '15 at 19:53
  • I've been using Eclipse for development. I've gotten these kinds of errors before but can't remember how to fix them. I did find a reference to "@layout/time_header_label" [here](https://android.googlesource.com/platform/frameworks/opt/datetimepicker/+/1f129e23db2dc5837a856f7734b15a5a8be6be94/res/layout/). That project targets version 17 with a minimum of 15. Maybe try downloading those SDK versions as well and see if it goes away. I usually end up downloading all versions anyway just so I have them. – VERT9x Mar 06 '15 at 20:03

2 Answers2

0

Other people also have this issue: See here

As the link suggests, a workaround is to lower your rendering api to 19.This stackoverflow answer shows how to do it.

Community
  • 1
  • 1
Nikos P.
  • 75
  • 2
  • 8
0

As specify in this link it is solved in api 22. Try to update your androidManifest.xml file after install Android 5.1.1 (Api 22) with the sdk manager

Miquelj
  • 80
  • 9