0

Big Nerd Ranch Android Programming book に従って最初の Android アプリを開始しました。最初の演習では、次の XML を入力する必要があります。

<LinearLayout xmlns:android="http://schema.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:gravity="center"
  android:orientation="vertical">

  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="24dp"
    android:text="@string/question_text"
  />

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

    <Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/true_button"
    />

    <Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/false_button"
    />
  </LinearLayout>
</LinearLayout>

ただし、グラフィカル ビューに戻すと、次のような一連のエラーが表示されます。

"<LinearLayout>" does not set the required layout_width attribute:
   (1) Set to "wrap_content"
   (2) Set to "match_parent"

クリックしてどちらかに設定すると、XML が次のように変更されます。

<LinearLayout xmlns:android="http://schema.android.com/apk/res/android"
  xmlns:android1="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android1:layout_width="match_parent"
  android:layout_height="match_parent"
  android1:layout_height="match_parent"
  android:gravity="center"
  android:orientation="vertical" >

私が使用することを主張し、どの値android1:も受け入れないのはなぜですか?android:

4

2 に答える 2

1

xml 名前空間宣言にタイプミスがあります:

xmlns:android="http://schema.android.com/apk/res/android"

する必要があります

xmlns:android="http://schemas.android.com/apk/res/android"
于 2013-10-05T19:19:50.653 に答える