1

我对 android/java 非常陌生,并且一直在关注一些 youtube 教程,并且在我的一个 xml 布局中遇到了一个严重的问题。

基本上,我在该部分android:hint的代码中收到“解析 XML 时出错:格式不正确(无效令牌)”错误。EditText谁能给我一个线索我做错了什么?(顺便说一句,代码可能是一团糟,因为我一直在搞乱只是想让它工作!)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="25dp" >

<EditText
    android:id="@+id/etCommands"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="@string/Type a command"
    android:inputType="true">
</EditText>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="100" >

    <Button
        android:id="@+id/bResults"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="20"
        android:text="@string/Try Command" >
    </Button>

    <ToggleButton
        android:id="@+id/tbPassword"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="80"
        android:checked="true"
        android:paddingBottom="3dp"
        android:text="@string/ToggleButton" />
</LinearLayout>

<TextView
    android:id="@+id/tvResults"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="@string/Invalid"
</TextView>

</LinearLayout>
4

1 回答 1

0
<TextView
    android:id="@+id/tvResults"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="@string/Invalid">   <--- you forgot to close bracket here
                                 ^^^  
</TextView>

而在你的EditText你正在设置你的提示string.xml

并确保你的没有问题string.xml

<EditText
    android:id="@+id/etCommands"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="SOME HINT" <----    Just try this testing purpose only
    android:inputType="true">
</EditText>
于 2012-08-06T13:30:00.213 回答