I know they changed how the constants in the resources class are stored in ADT 14 but how do I then get the id of an xml item since r.id.item gives an error now?
for example this gives me an error
mPager = (ViewPager)findViewById(R.id.pager);
this is my xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/pager"/>
</LinearLayout>
I suggest there is a different problem or you should clean your projects.
http://tools.android.com/recent/buildchangesinrevision14
Implies that the only problems you should encounter are using Id's for switches in library projects.
My personal experience is that things are fine (even in library projects, except switch)
Past some code or an error to get more help
Related
I am working on CrimeIntent app in Android Programming:
The Big Nerd Ranch Guide. I got a rendering problem when i put an EditText widget in a LinearLayout file for a fragment (fragment_crime.xml).Here is the code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText android:id="#+id/crime_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/crime_title_hint"/>
</LinearLayout>
I do not want to change the theme.
There is no error in your layout xml... possible it is the plugins and library loading issue in android studio... try to restart it or check the missing libraries and targets.. or check the #string/crime_title_hint if it exists in Strings.xml resources.
I'm working on an Android app that is supposed to run on android from 2.1 till the latest (4.4 right now). Everything worked fine until now, since the app decided to stop running on my Android 2.2 device. In the attached image is everything I think you're supposed to know to be able to help me.
I really don't know what is causing this, since the app runs fine on my Android 4.3.1 device.
The error I get is this:
"Binary XML file line #25: Error inflating class android.support.v7.internal.widget.ActionBarView"
It gives the error at SetContentView(Resources.Layout.Main);, which worked fine until now.
I've removed the main.axml file and readded it, but nothing changed, what should I change?
This is the main.axml file code:
<?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"
android:padding="12dp">
<FrameLayout
android:id="#android:id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="#+id/content_frame"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</FrameLayout>
</LinearLayout>
After doing a lot of research, and not finding anything... quick question, does anybody has an idea why Android Studio is not taking the Map tag? The code below is a fragment of the maps sample in the SDK. Already added google play services lib and support, but nothing.
It's showing the error
Unexpected namespace prefix "map" found for tag fragment.
Thanks a lot in advance!
<fragment
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"
map:cameraZoom="10" />
I had the same problem once I've been moving the map fragment into FrameLayout (so I could add a button on top of the map).
I don't know what I've really done as I'm a noob in Android apps and XML, but it looks that I found the solution :-)
I tried to make the trick including the fragment from a separate file (using 'include' directive) and once I put the bare map fragment without any namespace definitions it proposed me 2 options:
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:map="http://schemas.android.com/tools"
I realized that maybe the 2nd one will work in the original file (although in original file Android Studio is not proposing it, but only the 1st one instead).
Conclusion:
Just change this line:
xmlns:map="http://schemas.android.com/apk/res-auto"
with this:
xmlns:map="http://schemas.android.com/tools"
AS I MENTIONED - I'M A NOOB AND MAYBE MY SOLUTION GOT SOME SIDE EFFECTS SO PLEASE LET ME KNOW IF SO (although everything seemed to be working fine by so far...).
That's my working map layout with a button on the top and no errors:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/tools"
tools:context="com.maverickrider.myapp.inviteActivity.MapsActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/purpura_E51B4A">
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
map:cameraTargetLat="51.513259"
map:cameraTargetLng="-0.129147"
map:cameraTilt="30"
map:cameraZoom="13"
/>
<Button
android:id="#+id/startActivityButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:onClick="cokolwiek"
android:text="Baton z dupy"
android:layout_alignParentBottom="true"
/>
</FrameLayout >
I had this problem as well. I did Project/Clean and the error went away and it works fine now. This assumes that the map namespace is properly defined above where it's being used.
I'm running 0.5.8 and the XML viewer is underlining the attrs with map: - however the app is building fine. YMMMV.
I am trying to add a background to my android project. Heres the code.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backround="#drawable/awesome_face">
</RelativeLayout>
I spelled everything out correct but when i go into my graphical layout after saving and nothing shows up. Furthermore after i cleaned the project I now have an error on the
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
saying "no resource identifier found for attribute background in package 'android'" Anyone have ideas?
Just like ChristopheCVB said, your backgroud tag is missing a G.
android:backGround="#drawable/awesome_face">
I am trying to try out the tutorial online and wanted to put the tab to the layout xml. I have change the extends from Activity to TabActivity. In the design view of the layout xml, I have the below.
Error during post inflation process:
TabHost requires a TabWidget with id "android:id/tabs".
View found with id 'tabs' is 'com.android.layoutlib.bridge.MockView'
The following classes could not be found:
I have looked for solution but none of them fixed except I found one in different language. I tried using the translator on google but not so helpful.
Does anyone manage to get the tabs function.
I am using Android 2.2 Api and develop with an eclipse IDE
Known bug http://code.google.com/p/android/issues/detail?id=13092
A user suggested to switch build target to 1.6 and the issue goes away. Obviously a temporary fix.
You need a layout like this:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
</LinearLayout>
</TabHost>
See the Tab Layout tutorial for more info.
Do you have a TabWidget with id android:id/tabs as the error message tells you you need?
Switch to android Target 3.0 or 3.1. You can find that drop down list on the top right side
I had the same issue. The workaround is detailed in this link:
Comment 63 by blundell...#gmail.com, May 5, 2011
As stated above Quick Fix: Just change the API Target (top left of XML
graphical view) to 3.0 and you can see it