I am absolutely new to Java and Eclipse. I have two layout-files under /res/layout:
activity_main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<include layout="#layout/layoutTst" />
</LinearLayout>
layout_test.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/layoutTst"
android:orientation="vertical" >
</LinearLayout>
When I try to compile at the "include" - part I get this message:
Description Resource Path Location Type error: Error: No resource
found that matches the given name (at 'layout' with value
'#layout/layoutTst'). activity_main.xml /YouSherlock/res/layout line
6 Android AAPT Problem
So what is wrong?
You need to include the layout filename (layout_test.xml), not the ID of the root in that layout.
<include layout="#layout/layout_test" />
#layout/layoutTst
should be the name of the file not its android:id
#layout/layout_test
Related
I will put a adview (admob) in the bottom of a webview
When I gradle sync, I get this error. Could you please help me to solve this issue?
C:\Users\danie\AndroidStudioProjects\PokemonDamageCalculator\app\src\main\res\layout\activity_main.xml
Error:(20, 31) No resource found that matches the given name (at 'layout_above' with value '#id/adView').
C:\Users\danie\AndroidStudioProjects\PokemonDamageCalculator\app\build\intermediates\res\merged\debug\layout\activity_main.xml
Error:(20, 31) No resource found that matches the given name (at 'layout_above' with value '#id/adView').
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: Failed to execute aapt
This is my MainActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical"
tools:context="danilkp1234.com.pokemondamagecalculator.MainActivity">
<include
layout="#layout/content_main"
android:layout_width="match_parent"
android:layout_height="50dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/adView"
android:layout_weight="1"
android:orientation="vertical">
<WebView
android:id="#+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent">
</WebView>
</LinearLayout>
Replace
android:layout_above="#id/adView"
with
android:layout_above="#+id/adView"
Just need to add '+' after '#'
Where is the view with the id adView?
Also android:layout_above is used for views inside a RelativeLayout, not LinearLayout. In a RelativeLayout views can be placed below, on top or next to each other with android:layout_... attributes. LinearLayout automatically puts views below or next to one another depending on the android:orientation parameter.
If you want to continue using LinearLayout you should remove
android:layout_above="#id/adView"
I hope this helps.
You have an error in
android:layout_above="#id/adView"
At first try to change
#id/adView to #+id/adView.
Also,
android:layout_above="" is used in RelativeLayout, hence your LinearLayout won't affect any change. Change the parent LinearLayout to RelativeLayout and then add further View (havingid adView) to affect a change.
I was trying to porting the Tree-View-List-Android into my project recently. I have created a project called com.dotnetideas.treeview and added everything in. I can run the demo without any issue. But when I use it in another project, I kept getting “No resource identifier found for attribute 'indicator_gravity' in package com.dotnetideas.treeview” in main_demo.xml.
Here is the xml looks like.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:treeView="http://schemas.android.com/apk/res/com.dotnetideas.treeview"
android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">
<ListView android:layout_width="0dip" android:layout_height="0dip" android:scrollbars="vertical"
android:visibility="gone"> <!-- Just to test some attributes in IDE -->
</ListView>
<pl.polidea.treeview.TreeViewList android:id="#+id/mainTreeView" android:layout_width="fill_parent"
android:layout_height="fill_parent" treeView:indicator_gravity="right|center_vertical"
android:scrollbars="vertical" android:smoothScrollbar="true"/>
Although I followed the old code to changed the xml namespace from
xmlns:treeView=http://schemas.android.com/apk/res/pl.polidea.treeview
to
xmlns:treeView=http://schemas.android.com/apk/res/com.dotnetideas.treeview.
It doesn’t seem like valid xml namespace.
It turned out that the namespace needs to be
xmlns:treeView="http://schemas.android.com/apk/res-auto"
if we reference as a library project.
This answer from stackoverflow too didnt help.
<?xml version ="1.0" encoding ="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.Mapview
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:id="#+id/themap"
android:apikey = "AIzaSyDc9ac67bCYPqhVYz9pxhTJsK9shZH3iQg"/>
</LinearLayout>
it is my activity_main.xml file ...bt it shows the error mentioned above...i have also included android:name="com.google.android.maps" in my manifest file..plz help
Check whether in your project properties you have selected it as Google APIs
follow this if you still facing problem
I'am trying to load a spinner to my layout and keep geting this error:
The following classes could not be found:
- Spinner (Change to android.widget.Spinner, Fix Build Path, Edit XML)
heres my xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Spinner
android:id="#+id/spn_dates"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="displayDatesToSpiner" />
<ListView
android:id="#+id/LST_bought_products"
android:layout_width="match_parent"
android:layout_height="302dp" >
</ListView>
</LinearLayout>
Thanks
This sometimes happens when you rename the standard AppTheme in your android manifest. It will build and deploy just fine, but the xml design editor won't render it.
This is usually because there's an invalid attribute somewhere.
Remove the onClick and it will work.
This is really starting to drive me crazy.
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#id+/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="#string/hello"/>
Produces the following error message: "Error: no resource found that matches the given name (at 'id' with value '#id+/textview').
This is copy and pasted from the Android hello world
example.
#+id not #id+. Seems the tutorial is wrong!
It's just a small typo; you need to put the '+' after the '#', not after 'id':
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="#string/hello"/>