0
它說我的EditTexts無效。 我不知道它有什麼問題,但更具體的說,android:id是無效的。佈局無效(EditText)
<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"
tools:context=".SettingsActivity">
<TextView
android:id="@+id/text_view_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textColor="#FF0000"
android:textSize="20sp"
android:text="Testapp" />
<EditText
android:id="@+id/host"
android:layout_width="fill_parent"
android:gravity="center_horizontal"
android:layout_height="wrap_content"
android:layout_below="@+id/text_view_header"
android:inputType="textNoSuggestions"
android:hint="@string/host" />
<EditText
android:id="@+id/host2"
android:layout_width="fill_parent"
android:gravity="center_horizontal"
android:layout_height="wrap_content"
android:layout_below="@+id/spyhost"
android:inputType="textNoSuggestions"
android:hint="@string/host2" />
<Button
android:id="@+id/save"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_below="@+id/vidhost"
android:text="Save Settings"
android:onClick="onClickSave" />
</RelativeLayout>
編輯:修復很簡單。有些字符不會顯示,所以用新空格或製表符替換所有空格。原因很可能是從網站複製內容。由於在@Squonk
您的EditTexts和Buttons每個都有一個'android:layout_below'屬性,但是在那個'RelativeLayout'中沒有任何與這些屬性相關聯的id的小部件。 – Squonk 2014-12-13 11:45:35