2012-08-06 95 views
1

我對android/java很新穎,並且一直在關注一些YouTube教程,並且在我的一個xml佈局中遇到了一個嚴重問題。Android類型錯誤:解析XML時出錯:格式不正確(無效標記)

基本上,我在EditText部分中的代碼的android:hint上發生'錯誤解析XML:格式不正確(無效標記)'錯誤。任何人都可以給我一個線索我做錯了什麼? (順便說一下那裏有機會的代碼可能是因爲我一直在瞎搞只是想獲得它的工作一塌糊塗!)

<?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> 
+0

關閉TextView的 – Dharmendra 2012-08-06 13:31:44

回答

1
<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> 
+0

感謝您的球員的支架。我已經關閉了文本視圖,但仍然存在我的問題。我現在有一個問題,與我的其他類錯誤'R無法解決' – user1352057 2012-08-06 15:18:19

+0

因爲這看到這個答案http://stackoverflow.com/a/11467781/1289716 – MAC 2012-08-06 15:24:30

相關問題