下記のコードを書いて、3列×3段の9個のボタンを作りました。
エミュレーターで確認しようとしたらエラーが出てしまいました。
内容を見ましたが、何が間違ってるのか分かりません。
javaのほうでも、setContentView(R.layout.activity_main)部分のRだけが赤くなってしまいました。
どこを直せばいいのでしょうか?
<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="com.example.hongo.numbergame.Main2Activity">
</RelativeLayout><Button android:id="@+id/button1_1" android:text="1" android:layout_alignTop="@id/button1_2" android:layout_toLeftOf="@id/button1_2" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <Button android:id="@+id/button1_2" android:text="2" android:layout_above="@id/button1_5" android:layout_alignLeft="@id/button1_5" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <Button android:id="@+id/button1_3" android:text="3" android:layout_alignTop="@id/button1_2" android:layout_toRightOf="@id/button1_2" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <Button android:id="@+id/button1_4" android:text="4" android:layout_alignTop="@id/button1_5" android:layout_toLeftOf="@id/button1_5" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <Button android:id="@+id/button1_5" android:text="5" android:layout_centerInParent="true" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <Button android:id="@+id/button1_6" android:text="6" android:layout_alignTop="@id/button1_5" android:layout_toRightOf="@id/button1_5" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <Button android:id="@+id/button1_7" android:text="7" android:layout_alignTop="@id/button1_8" android:layout_toLeftOf="@id/button1_8" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <Button android:id="@+id/button1_8" android:text="8" android:layout_below="@id/button1_5" android:layout_alignLeft="@id/button1_5" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <Button android:id="@+id/button1_9" android:text="9" android:layout_alignTop="@id/button1_8" android:layout_toRightOf="@id/button1_8" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
エラーメッセージ
Error:(17, 34) No resource found that matches the given name (at 'layout_alignTop' with value '@id/button1_2').
Error:(18, 34) No resource found that matches the given name (at 'layout_toLeftOf' with value '@id/button1_2').
Error:(25, 31) No resource found that matches the given name (at 'layout_above' with value '@id/button1_5').
Error:(26, 35) No resource found that matches the given name (at 'layout_alignLeft' with value '@id/button1_5').
Error:(41, 34) No resource found that matches the given name (at 'layout_alignTop' with value '@id/button1_5').
Error:(42, 34) No resource found that matches the given name (at 'layout_toLeftOf' with value '@id/button1_5').
Error:(64, 34) No resource found that matches the given name (at 'layout_alignTop' with value '@id/button1_8').
Error:(65, 34) No resource found that matches the given name (at 'layout_toLeftOf' with value '@id/button1_8').
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/11/07 17:09