10

Rendering Problems Couldn't resolve resource @id/search_edit_frame

This is the rendering error I'm getting in my xml file. I think it has something to do with my support.v7.SearchView below is my xml:

 <RelativeLayout
    android:id="@+id/layout_ricerca"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:background="@drawable/search_border_backgroud"
    android:layout_marginStart="10dp"
    android:layout_marginEnd="10dp"
    android:layout_marginTop="20dp">

    <android.support.v7.widget.SearchView
        android:id="@+id/testo_ricerca"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:queryHint="@string/search_hint"
        android:textSize="25sp"
        android:layout_marginStart="5dp"
        android:iconifiedByDefault="false"/>

    <ImageButton
        android:id="@+id/tasto_ricerca"
        android:background="@color/trans"
        android:layout_marginTop="2dp"
        android:layout_width="45dp"
        android:layout_height="match_parent"
        android:layout_marginEnd="3dp"
        android:scaleType="centerInside"
        android:layout_alignParentEnd="true"
        android:src="@drawable/tasto_ricerca"/>
</RelativeLayout>

When I change the <android.support.v7.widget.SearchView to <SearchView the error disappears, but that's not a good solution for me because I would have to change all my java code to work with the SearchView instead of the android.support.v7.widget.SearchView.

Does anyone know how to fix this problem ? why does it happen? I don't think there is anything wrong with my xml.

Edit:

Added screenshot of the error

screenshot

Harshad Pansuriya
  • 20,189
  • 8
  • 67
  • 95
Daniele
  • 4,163
  • 7
  • 44
  • 95
  • Related [Couldn't resolve resource @id/visible when using TextInputLayout](https://stackoverflow.com/a/42079386/7034327) – John Nov 24 '17 at 07:58

6 Answers6

16

To resolve this issue, provide an

android:id="@+id/search_edit_frame"

attribute to a parent view such as

android.support.design.widget.AppBarLayout

or any ViewGroup that is parent to your SearchView.

For example:

<android.support.design.widget.AppBarLayout
  android:id="@+id/search_edit_frame"
  android:layout_width="match_parent"
  android:layout_height="@dimen/my_app_bar_height">

  <android.support.v7.widget.SearchView
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<android.support.design.widget.AppBarLayout />
Chad Mx
  • 1,266
  • 14
  • 17
6

When you have lot of cache memory data are store in Android Studio that time this type of error is coming..

There are many way to solve it.

  1. Quickest way to do that is FileInvalidate caches / Restart...Just Restart.

  2. Right click on project and Synchronize ...Project

  3. click on Build menu --> select Clean Project and then Rebuild it.
Harshad Pansuriya
  • 20,189
  • 8
  • 67
  • 95
1

use this code

<SearchView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/searchView"
android:iconifiedByDefault="true"
android:queryHint="Search"
android:layout_centerHorizontal="true" />
Rinku Vashist
  • 355
  • 3
  • 14
1
    android:id="@+id/search_edit_frame"

add above line to parent layout that did the trick for me

-1

Here is an easy one solution.

There is no need of invalidating cache Or restarting. Just add below line into your strings.xml file and problem will get solved.

 <item name="search_edit_frame" type="id"/>

Bingo!

kamranbhatti585
  • 232
  • 2
  • 16
-1

I have the same problem but in eclipse IDE and I solved it by 1- click on project --> clean and it solved the problem with me