<RelativeLayout 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:background="#drawable/background1"
tools:context="com.example.flavours.Category" >
<ImageView
android:id="#+id/homeimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerInParent="true"
android:src="#drawable/ice1"/>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="25dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
Each time I had a problem with R (R.id/layout) not been generated after change build target (6.0) to (5.0.1).
I already cleaned the project multiple times and whn i cleaned my project instantly i get error on "r"(R cannot be resolved to a variable) .I also import my (com.example.flavours.R;) but it remove whn i press Ctrl+shift+o.
i checked your code and i tested it ,
its true and works !
make sure that your new .xml file,has a valid name
valid name contains only
lowercase letters `a-z`
numbers `0-9` and they should`nt be in the first of file name.
underline `_`
also right click on the project and cleanup the source
Right Click On Project > Source > Clean Up...
or check build path for unwanted changes
Right Click On Project > Build Path > Configure Build Path...
Related
I am not able to add image. I downloaded the image and added it to res directory under drawable-mdpi. Then when I try to add the image on the view using imageView, it gives me this error
Couldn't resolve resource #drawable/ball01
Failed to convert #drawable/ball01 into a drawable
Here is my xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:ignore="MergeRootFrame" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView"
android:layout_gravity="center"
android:textSize="32sp"
android:layout_above="#+id/button"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Enlighten Me"
android:id="#+id/button"
android:layout_centerVertical="true"
android:layout_alignParentRight="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:layout_above="#+id/textView"
android:layout_centerHorizontal="true"
android:src="#drawable/ball01" />
</RelativeLayout>
What am I doing wrong here.
The directory name should be 'drawable-mdpi'. Using a hyphen instead of an underscore.
image name must Digital or lowercase 。 ide only identification.
I had this same problem, I had this image which I named Barcode and then saved it into my drawable folder, then I decided it would be better to have it named barcode with a small b, so I renamed it.
Then I checked if it would work, and I got the same errors as you, after changing the name in my xml to 'Barcode' with a big B, it worked.
solution for me: delete barcode image from drawable and add it again with the name I'm going to use for it, don't change the name while it is in drawable folder.
I had this problem on android studio.
if you close and open project and it continues, all you need to do is RIGHT CLICK on the particular image you put in your "res" folder (that's giving the problem) and refactor-RENAME. Remove spaces in the name of the file. that should do it.
When clean and build project getting error in eclipse console. And one more thing R.java in not be created it show error on R.
Error are like
W/ResourceType( 7964): Bad XML block: header size 85 or total size 5529592 is larger than data size 0.
Any help guys why this happened?
I am using these two xml
itemlist.xml
<TextView
android:id="#+id/txtNewsSource"
android:layout_width="110dp"
android:layout_height="110dp"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:layout_margin="5dp"
android:background="#64CBD8" />
and secone one main.xml
<com.krish.horizontalscrollview.CenterLockHorizontalScrollview
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
</com.krish.horizontalscrollview.CenterLockHorizontalScrollview>
<LinearLayout
android:id="#+id/bottomLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/scrollView"
android:orientation="horizontal"
android:weightSum="2" >
<Button
android:id="#+id/btnPrev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Prev" />
<Button
android:id="#+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Next" />
</LinearLayout>
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/bottomLayout"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:textColor="#FF0000"
android:padding="#dimen/padding_medium" />
First Copy "android-support-v4.jar" from your main project libs and paste it in your all external libraries.(Mean replace all android-support-v4.jar with you main one support library.)
Ensure that there is no duplication of xml data (let say:same code in your external library string file and in your main project's string file.)
Remove all external libraries, Clean+build your project.
Again include your external libraries one by one and clean.
"W/ResourceType( 8032): Bad XML block: header size 85 or total size 5529592 is larger than data size 0"
Means that you have a malformed XML resource.
You need to solve the XML error then you clean build your project.
Please validate your XML online
First Clean project from project menu
Then fix import in in your class file like this:
import com.your.package.xyz.R;
I wrote code for Admob. This is my layout.xml file code:
<RelativeLayout 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:background="#ffffff"
android:id="#+id/relativeLayoutHomeParent"
tools:context=".Home" xmlns:app="http://schemas.android.com/apk/lib/com.google.ads">
<RelativeLayout
android:id="#+id/relativeLayoutHomeTopBar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
<TextView
android:id="#+id/textView1"
android:text="Home"
style="#style/screen_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="#+id/imageViewHomeSettings"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="#drawable/set_settings"
android:layout_marginRight="10dp" />
</RelativeLayout>
<View
android:id="#+id/view1"
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_below="#+id/relativeLayoutHomeTopBar"
android:background="#drawable/shadow" />
<ListView
android:id="#+id/listViewHome"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#BDBDBD"
android:dividerHeight="1dp"
android:layout_below="#+id/view1" >
</ListView>
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
app:adSize="BANNER"
app:adUnitId="a1512f50d8c3692"
app:loadAdOnCreate="true"
app:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" >
</com.google.ads.AdView>
Output:
I want the bar that is on the top(yes that black bar), on the bottom of the screen. I also wrote for it but it showed the output as the above image.
Also i dont understand that which one is the admob banner, the top one or the bottom one ?? Can anyone please explain the difference these two bars. Actually i am new to this. This is the first time i've code for admob. Please help me to learn on this.
Maybe the ADK update has messed-up with your project's build-path. Try removing the admob JAR and add it again to your libs folder, add it to your Build Path and do a Clean Project.
EDIT following poster's comment about not having a libs folder:
You should try this:
Remove all references to the AdMob JAR in your project -> your code should not build without error anymore
Create a libs folder at the root of your project.
Copy the AdMob JAR into the libs folder
Make sure this AdMob JAR is in your Build Path (this will allow your code to build wihtout error)
(If still not running OK) Right click your project > Android Tools > Fix Project Properties
When trying to view the Graphical Layout view I am getting the following error:
The following classes could not be found - EditText (Change to
android.widget.EditText, Fix Build Path, Edit XML)
The app works fine and I can edit the XML without any problems. I just can't load the graphical layout view anymore. In the Main.java file there are no problems or errors importing the EditText widget from the Android library.
I'm using Eclipse Indigo Service Release 2. Got all the recent updates.
I'm also using the latest Android SDK Tools 20.0.1
Here is the source. I've tried the option to Source > Cleanup Document and Format just to make sure the XML was correct.
<?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/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="63dp"
android:text="#string/button1" />
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="16dp"
android:ems="10"
android:inputType="" >
<requestFocus />
</EditText>
</RelativeLayout>
I managed to fix the problem.
I had to change
android:inputType=""
to
android:inputType="text"
The Graphical Layout view now works again.
this is because if you are using api 4.4W which is recently released for android wear
and Android wear doesnot support edittext
http://developer.android.com/training/building-wearables.html
I have constantly gotten the same error over and over in my program and i can't find out how to fix it. R cannot be resolved to an error. I have tried to build my project and i have no imports that involve .R? Would anyone know how to fix it?
Here's my xml files i can't seem to find anything wrong....
strings.xml
Remote Doc
Remote Doc
Patient Mode
Doctor Mode
About
Exit
Simple Mode
Detailed Mode
About Remote Doc
\
Remote Doc is an application that allows a brace user analyze
how often they use their thing
main.xml
<!-- Patient Option -->
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/patientButton"
android:id="#+id/patientButton">
</Button>
<!-- Doctor Option -->
<Button android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/doctorButton"
android:layout_weight="1"
android:id="#+id/doctorButton">
</Button>
<!-- Exit Mode -->
<Button android:text="#string/exit"
android:layout_weight="1"
android:id="#+id/exit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"></Button>
<!-- About Mode -->
<Button android:text="#string/aboutButton"
android:layout_weight="1"
android:id="#+id/aboutButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"></Button>
</LinearLayout>
/>
main.xml- land
android:text="#string/mainTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="20dip"
android:textSize="24.5sp"/>
<TableLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:stretchColumns="*">
<TableRow>
<Button
android:text="#string/patientButton"
android:id="#+id/patientButton"/>
<Button
android:text="#string/doctorButton"
android:id="#+id/doctorButton"/>
</TableRow>
<TableRow>
<Button
android:text="#string/aboutButton"
android:id="#+id/aboutButton"/>
<Button
android:text="#string/exit"
android:id="#+id/exit"/>
</TableRow>
</TableLayout>
</LinearLayout>
This is a really common problem. First try cleaning your project by going to Project > Clean.
If that doesn't work, try one of the recommendations from this similar question
R is an automatically generated class in Android. It holds all your ressource references.
Since the creation of that failed, you will most likely have an error inside one of
your ressource files. (e.g. syntax error in a layout file like main.xml, or in your strings.xml). Check these files inside the res/ folder. Probably in the one you most recently edited.
After your are done and found it, this should go away automatically. Sometimes it gets stuck though, then do a project clean. Inside eclipse select Project->Clean.