RelativeLayout
後でやりたいことのテストとして、これを非常に簡単に作成しました。現在のところ、 、second
、 の3 つのボタンが互いに相対的に配置されているはずです。alpha
mode
問題が 2 つあります。1 つ目は、XML レイアウト ファイルに何か問題があり、徹底的にチェックしたので何が原因かわかりません。これにより、レイアウトの 10 行目と 11 行目でエラーが発生します。R
第 2 に、通常は Android アクティビティにあるため、生成されたファイルはありません。これにより、R ファイルから何かを呼び出そうとするため、メイン コードの 11 行目でエラーが発生します。
私のコードは次のとおりです。
レイアウト:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/second"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/alpha"
android:layout_toLeftOf="@id/mode"
android:text="@string/second"
android:layout_alignParentLeft="true" />
<Button
android:id="@+id/alpha"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/second"
android:layout_alignParentLeft="true"
android:text="@string/alpha" />
<Button
android:id="@+id/mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/second"
android:layout_alignParentLeft="true"
android:text="@string/mode" />
</RelativeLayout>
メインActivity
コード:
package com.example.TI84;
import android.app.Activity;
import android.os.Bundle;
public class TI84GraphingCalculatorActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
ご協力ありがとうございました!