'<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/droid_background" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:text="#string/hello"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<GridView
android:id=”#+id/videoGrdVw”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:numColumns=”auto_fit”
android:verticalSpacing=”5dip”
android:horizontalSpacing=”5dip”
android:columnWidth=”80dip”
android:stretchMode=”columnWidth”
android:gravity=”center”/>
</RelativeLayout>
You've got fancy quotes mixed in with regular plain old quotes - replace the ”s with "s and it should work.
It looks like there's a strange problem with the quotes that you've posted. Some of them are of a different type than the others - look at the ones in the GridView. I would try changing them to be the same as the quotes up above and see if that helps.
Related
I downloaded sample android carousel demo source code in the below link http://www.codeproject.com/Articles/146145/Android-3D-Carousel#xx4884593xx
The main.xml is as follows:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:pj="http://schemas.android.com/apk/res/carousel.main"
xmlns:bm="carousel.main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/back"
android:orientation="vertical" >
<TextView
android:id="#+id/selected_item"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:background="#1E1921"
android:text="text"
android:textColor="#A85E4F"
android:textStyle="normal"
android:visibility="gone" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:gravity="top"
android:padding="5dip" >
<carousel.Carousel
android:id="#+id/carousel"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:animationDuration="200"
pj:Items="#array/entries"
pj:SelectedItem="0"
pj:UseReflection="true" />
</LinearLayout>
</LinearLayout>
However I'm now getting the following errors:
Description Resource Path Location Type
error: No resource identifier found for attribute 'UseReflection' in package 'carousel.main' main.xml
Suspicious namespace: should start with http:// main.xml
Each time I try and clean the project it deletes the R.file. I've tried changing the package name, and pasting all the contents again but that hasn't solved the problem.
I found where the problem was.
In the root of the xml:
xmlns:pj="http://schemas.android.com/apk/res/package_with_calling_class"
xmlns:bm="package_with_calling_class"
package_with_calling_class = the class which might be the main activity where the onCreate() is being called. In my case it was platinum.platinumstars
setContent(R.layout.main)
I have a rather simple ListView row:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/tournament_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textSize="25dp" />
<TextView
android:id="#+id/tournament_winner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textSize="25dp" />
</RelativeLayout>
When the text of "#+id/tournament_name"is long - it overlaps with the one from "#+id/tournament_winner" and I don't understand why.
I tried using android:singleLine="false"to no avail. I also tried using android:inputType="textMultiLine"as the docu says android:singleLine="false" is deprecated but then I get the warning: Attribute android:inputType should not be used with <TextView>: Change element type to
<EditText> ? so no good here as well.
I also tried using android:ellipsize="end" but this doesn't work. I assume it is because the text in the left TextView ("#+id/tournament_name") is NOT long enough to fill up the full width of the ListView (which code is not sowing here).
I was sure that if I use android:layout_width="wrap_content"the two TextView fields shouldn't overlap.
Here is an example (see the second line):
Any further ideas how this could be fixed?
android:layout_toLeftOf="#id/tournament_winner" in First TextView.
Also set android:maxLines="1" and Fix width for tournament winner because when it gets long tournament name cant see...
row.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/tournament_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#id/tournament_winner"
android:maxLines="1"
android:text="NAMEEEEEEEEEEEEEEEEEEEEEEEEEEE"
android:textSize="25dp" />
<TextView
android:id="#+id/tournament_winner"
android:layout_width="wrap_content" android:layout_marginLeft="10dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="WINER"
android:textSize="25dp" />
</RelativeLayout>
Thank you very much for your answer - sorry it took me some time to respond. I ended up using your android:layout_toLeftOf="#+id/tournament_winner" but left the single line and the margin to the left unused, as the result seemed perfect to me (hope this is also the case for other devices).
One thing though - in the first text view (tournament_name) I had to use android:layout_toLeftOf="#+id/tournament_winner"and not android:layout_toLeftOf="#id/tournament_winner" - pay attention to the added +. For some reason I get an error using android:layout_toLeftOf="#id/tournament_winner": Error: No resource found that matches the given name... so it seems that it is possible and NEEDED to define the resource in the time of calling it because the system doesn't know it before it was defined.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/tournament_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/tournament_winner"
android:layout_alignParentLeft="true"
android:textSize="25dp" />
<TextView
android:id="#+id/tournament_winner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textSize="25dp" />
</RelativeLayout>
You can use single text view in place of two and simply display both strings in one text view !!
I'm a beginner android developer , I was trying to run this Linear Layout in eclipse :
<?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">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:text="red"
android:gravity="center_horizontal"
android:background="#aa0000"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"/>
<TextView
android:text="green"
android:gravity="center_horizontal"
android:background="#00aa00"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"/>
<TextView
android:text="blue"
android:gravity="center_horizontal"
android:background="#0000aa"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"/>
<TextView
android:text="yellow"
android:gravity="center_horizontal"
android:background="#aaaa00"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:text="row one"
android:textSize="15pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView
android:text="row two"
android:textSize="15pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView
android:text="row three"
android:textSize="15pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView
android:text="row four"
android:textSize="15pt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
And, I noticed :
1) yellow line under android:text="Yellow"
2) yellow line under android:text="row four"
the Triangle warn says [I18N] Hardcoded string "Yellow", should use #string resource "
and same for the rest of the warnings.Any suggestion?
It is not good practice to hard code strings into your layout files. You should add them to a string resource file and then reference them from your layout.
This allows you to update every occurrence of the word "Yellow" in all layouts at the same time by just editing your strings.xml file.
It is also extremely useful for supporting multiple languages as a separate strings.xml file can be used for each supported language.
example:
XML file saved at res/values/strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="yellow">Yellow</string>
</resources>
This layout XML applies a string to a View:
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/yellow" />
Similarly colors should be stored in colors.xml and then referenced by using #color/color_name
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="Black">#000000</color>
</resources>
You must create them under
strings.xml
<string name="close">Close</string>
You must replace and reference like this
android:text="#string/close"/>
Do not use #strings even though the XML file says strings.xml or else it will not work.
It is not good practice to hard code strings into your layout files/ code. You should add them to a string resource file and then reference them from your layout.
This allows you to update every occurrence of the same word in all
layouts at the same time by just editing your strings.xml file.
It is also extremely useful for supporting multiple languages as a
separate strings.xml file can be used for each supported language
the actual point of having the #string system please read over the
localization documentation. It allows you to easily locate text in
your app and later have it translated.
Strings can be internationalized easily, allowing your application
to support multiple languages with a single application package file
(APK).
Benefits
Lets say you used same string in 10 different locations in the code.
What if you decide to alter it? Instead of searching for where all it
has been used in the project you just change it once and changes are
reflected everywhere in the project.
Strings don’t clutter up your application code, leaving it clear and
easy to maintain.
You can go to Design mode and select "Fix" at the bottom of the warning. Then a pop up will appear (seems like it's going to register the new string) and voila, the error is fixed.
A good practice is write text inside String.xml
example:
String.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="yellow">Yellow</string>
</resources>
and inside layout:
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/yellow" />
Apart from the multiple language special case, what is wrong with the global find & replace approach as used in almost every other environment?
The 'one place' argument seems spurious. Changing a string of 'yellow' would not affect another of e.g: 'yellow paint'!
I was trying to do an adapter on a ListView as an exercise but I get a strange error on the row layout:
error: Error parsing XML: unbound prefix
What is wrong with this very simple Layout??!?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/station"
android:text="Stazione DI"
android:layout_alignParentTop="true"
android:padding="3dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<TextView
androdi:id="#+id/time"
android:text="Time:"
android:layout_alignParentLeft="true"
android:below="#id/station"/>
<TextView
androdi:id="+id/late"
android:text="Time:"
android:layout_toRightOf="#id/time"
android:below="#id/station"/>
<TextView
androdi:id="+id/rail"
android:text="Rail:"
android:below="#id/station"
android:layout_toRightOf="#id/late"/>
</RelativeLayout>
Prefixes are those strings you type before the :, like android:.... And you typed it wrong once (androdi:...)
(edit: actually 3 times)
Prefixes in Last TextView spell not correct, check that
In xml file last Textview is worong
<TextView
androdi:id="+id/rail"
android:text="Rail:"
android:below="#id/station"
android:layout_toRightOf="#id/late"/>
It will be
<TextView
android:id="+id/rail"
android:text="Rail:"
android:below="#id/station"
android:layout_toRightOf="#id/late"/>
you have written android spelling wrong in following cases !
androdi:id="#+id/time"
androdi:id="+id/late"
androdi:id="+id/rail"
I'm using TableLayout to display data.
Text of the TextViews of the right column will be set when activity calls onCreate().
Now, as you can see in the following image that my address text can be long and it should be wrapped.
So I set android:layout_width="wrap_content". but it still take a width of screen size to wrap data.
How can I overcome from this issue?
My xml:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5px">
<TableRow>
<TextView android:text="Job#"
android:paddingRight="5px" />
<TextView android:id="#+id/DetailJobNo" />
</TableRow>
<TableRow>
<TextView android:text="Address"
android:paddingRight="5px" />
<TextView android:id="#+id/DetailAddress"
android:layout_width="wrap_content"
android:text="Address Address Address Address Address Address Address Address "/>
</TableRow>
</TableLayout>
Adding android:shrinkColumns="1" to TableLayout solves my issue.
Can you try setting setHorizontallyScrolling to the DetailAdress TextView to false?
#Vikas, its good that you have solved your problem.
BUt I would still recommend to use HorizontalScrollView for security purposes. If at all few chars are not visible, then horizontal scrollbar will help to manage that. XML text :
<HorizontalScrollView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginBottom="10dp" >
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5px">
......
......
ADD YOUR ROWS
</TableLayout>
</HorizontalScrollView>
Its always better to take care of the unexpected.