rendering error; couldn't resolve #id/search_edit_frame - android

I am having an error that says couldn't resolve #id/search_edit_frame I don't know why,
I tried the File>Invalidate Caches> Just Restart and restart android studio also tried to change the render version all of my supported api..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
myapp="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.SearchView
android:id="#+id/svSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="25sp"
android:textColor="#color/textDefault"
myapp="#string/search_hint"
myapp="false" />
</LinearLayout>
I'm using Android Studio 1.2.2 and sure that it compiles android.support.v7.widget(AppCompat)
any help will be appreciated.. thanks

Use
<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" />
it should work

First, you can search #id/search_edit_frame in all your xml file to check where it comes from.
Second, if you are sure that there is no #id/search_edit_frame in your xml, then you can try to delete all files in your Build folder.
Try to clean your project also.

Related

Android Studio: "Cannot perform refactoring. This element cannot be renamed"

I would like to change the name of the graphics, but android studio shows an error:
"Cannot perform the refactoring. This element cannot be renamed"
On the left is a tutorial on where it works, and on the right my code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/name_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/name"
android:textAlignment="center"
style="#style/NameStyle" />
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="#android:drawable/btn_star_big_on"
/>
</LinearLayout>
Refactor works only in the id window:
Why doesn't it work in XML code?
This is the first project on Kubuntu 20.04 LTS.
You are trying to rename a built in drawable of the android platform while the tutorial screenshot you posted is trying to rename the id of the view
What I mean is
The resources having the #android: as prefix are the ones that are built in the android platform and thus can't be refactored or renamed and your screenshot is trying to rename like so. You can see the dialog title Rename xyz and its occurence to which indicates what element you are trying to rename
<ImageView
android:id="#+id/imageView" // This is being changed in the screenshot
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="#android:drawable/btn_star_big_on" // You are trying to change this

Rendering Problems Couldn't resolve resource #id/search_edit_frame

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
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 />
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.
Quickest way to do that is File → Invalidate caches / Restart...
→ Just Restart.
Right click on project and Synchronize ...Project
click on Build menu --> select Clean Project and then Rebuild
it.
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" />
android:id="#+id/search_edit_frame"
add above line to parent layout that did the trick for me
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!
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

Android sdk 21 library errors

I installed Android SDK 21 bundle Windows x64 and get nothing but errors if I try to add any code to the initial project creation code. I tried running through the Hello World and every entry gave an error. BTW: I am a newbie with Android and Linux, but I have done a lot of Windows programming. thanks...
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<EditText android:id="#+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="#string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send" />
</LinearLayout>
EDIT: removed redundancy.
Your last Button(button_send) didn't have any parent view.
You should to put that into a view like LinearLayout or others.
Try:
1) reloading Eclipse
2) running the Project Clean.

RelativeLayout not working properly Android

I have the next problem: I use a lot the RelativeLayout, like the Android documentation is telling me to do. But, since few days, I don´t understand why, this is not working anymore:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#drawable/background"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/boton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Button" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/boton"
android:layout_centerHorizontal="true"
android:layout_marginTop="60dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000" />
</RelativeLayout>
This is my layout, very simple. So, according to this one, the textView should be BELOW the button, but, instead, it appears OVER the button!
.
Сan anyone explain me what happens?
EDIT: The problem is not when I try to run it on a device, the problem comes when I see it on the graphical layout of the ADT Plugin for Eclipse...
I try this code it's working properly.
If your side not working properly Try to Clean build your project and then Run.
If still having problem then Try this
android:layout_below="#+id/boton"
remove above line with this
android:layout_below="#id/boton"
Because "+" create new reference to R.java file
This may be the issue.
try by removing the below line from your code
android:layout_marginTop="60dp"
Take the '+' sign out of the TextView's layout_below attribute. The '+' tells it to deine a new id. Without the '+' it should refer to the existing one.
I think your issue is the drawable for the background, since I am not seeing an image in your preview.
Having this issue is giving you a build error so the preview doesn't show the layout in its current state (it reverts to the last sucessful build). Either remove that line and save to see the preview or check to make sure that you have an image in your drawables folder titled "background"
Try this, without the drawable to check if it is working for you:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/boton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Button" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/boton"
android:layout_centerHorizontal="true"
android:layout_marginTop="60dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000" />
</RelativeLayout>
I am trying to run it, and now, I know what´s the problem.
When running the app in a terminal, it is working properly, the problems comes when I try to see it on the graphical layout on the ADT plugin on Eclipse! Anyone with the same problem??
Add </RelativeLayout> at the end of your relative layout to close it.

Relative layout error aginst google api7 build

I'm trying to display the device's position on a map. i got my app working but the map wouldn't display. I've done lots of reading on the common errors for this eg map api key. my phone is a samsung galaxy 2.1. i noticed that i was building against google api8. so i mess up a bit on a few things and had to delete the project and copy and paste the src files back into a new project. the new project is built against google api7 now.
the problem is that the main.xml file has an error in it. The only thing i can think of is that i've changed what the project is built against api7 instead of api8. any ideas?
error: Error: String types not allowed (at 'layout_width' with value 'match_parent').
[edit] the error is in the relativelayout tag
.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content" android:gravity="fill">
<com.google.android.maps.MapView
android:id="#+id/myGMap"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="02wE28syQIHzpwXXa95CrtA1XJLU5segJgltvKQ"
/>
<EditText android:id="#+id/edittext1"
android:inputType="text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="CLOSE"
android:layout_alignParentRight="true"
android:id="#+id/close" ></Button>
</RelativeLayout>
Yes, in api level 7 there is no xml attibute match_parent exist, instead you need to use fill_parent.

Categories

Resources