【问题标题】:Element type "textview" must be followed by either attribute specifications, ">" or "/>"元素类型“textview”必须后跟属性规范,“>”或“/>”
【发布时间】:2014-10-23 04:34:43
【问题描述】:

错误在最后一行。而且我不知道在这里做什么或什么代码可以工作。如果有人能告诉我他们为解决这个问题做了什么,我会很高兴。

<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.jokeoftheday.MainActivity" >

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="90dp"
    android:text="@string/Your joke of the day is:"
    android:textSize="18sp" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView2"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="61dp"
    android:text="@string/The problem with twitter is that you always run out of chara-" >
</TextView>

【问题讨论】:

  • 你的第二个 TextView 没有关闭。
  • 您使用 @string/ 错误。如果您想简单地硬编码您的值,那很好,但请删除 @string/ 部分。只有在使用 strings.xml 文件时才会使用它,然后使用指定文本的 ID

标签: java android attributes textview element


【解决方案1】:

只需将最后一个 textview 的内容与 textview 中的内容进行比较即可。

看看以前,你没有 ?您只是在所有属性的末尾添加了 /> 。您需要将最后一个块更改为:

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView2"
android:layout_centerHorizontal="true"
android:layout_marginTop="61dp"
android:text="@string/The problem with twitter is that you always run out of chara-" />

这很容易解决!

希望对您有所帮助。祝你好运:)

【讨论】:

    【解决方案2】:

    两个问题

    1. 文本 ID 不得包含“空格”,因此“问题....”
    2. 这是主要问题,您缺少
    3. 的“结束”

    注意:

    TextView 的两个“结束”都是合法且有效的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-12
      • 2012-01-23
      • 1970-01-01
      • 1970-01-01
      • 2015-10-27
      • 2014-01-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多