android eclipse error:Error: no resource found that matches the given name (at 'text' with value '@string/red')
This is definitely driving me a little crazy because I am literally at tutorial one of learning android and I have already encountered a pair of problems.
First being that when I apply android:gravity="center"
the text only centers vertically but not horizontally, then to make matters worse if I change the helloworld example textview android:text="@string/red"
and then go to the strings.xml and change the default value to <string name="red">redflashlight</string>
the graphical layout shows the text as @string/red
instead of "redflashlight".
This is concerning because I am literally following a video tutorial and I am doing exactly what the author is doing, I am worried that perhaps its a problem with the sdk or eclipse? perhaps my operating system being vista? I really dont know, any help would b amazing thanks in advance.
here is my main.xml:
<?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:gravity="center"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/red"
/>
</LinearLayout>
and here is my strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="开发者_StackOverflow中文版red">redflashlight</string>
<string name="app_name">simple flashlight</string>
</resources>
To make the text center in both vertically and horizontally,
<?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:gravity="center_vertical"
><TextView
android:gravity="center_horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/red"
/></LinearLayout>
I try your code and its working properly. I think your project is not build properly. So, build it: Project->Build Automatically from the menu bar of eclipse.
精彩评论