私はゲームを作っていて、現在このJavaファイルを持っています
package pap.crowslanding;
import android.os.Bundle;
public class Game extends MainActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.tester1);
}
}
カスタム レイアウトの GameView を使用して、xml ファイル tester1 とマージしようとしました
<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"
android:background="@drawable/cl_bg"
android:gravity="fill_horizontal">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="32dp"
android:layout_marginTop="42dp"
android:text="@string/hello_world" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="31dp"
android:orientation="horizontal" >
<Button
android:id="@+id/play_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/custom_button"
android:text="@string/first_button"
android:textColor="@drawable/text_color_white" />
<Button
android:id="@+id/sbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/custom_button"
android:text="@string/menu_settings"
android:textColor="@drawable/text_color_white" />
</LinearLayout>
</RelativeLayout>
<pap.crowslanding.GameView
android:id="@+id/GameView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></pap.crowslanding.GameView
>
</RelativeLayout>
今:
setContentView(R.layout.tester1);
何らかの理由で動作しませんが、
setContentView(GameView(this));
動作します、助けてください
これが簡単に思える場合は申し訳ありませんが、私はかなり新しく、まだ頭を悩ませています。読んでくれてありがとう。