I'm making a game and currently I have this java file
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);
}
}
Using my custom layout GameView, I have tried to merge it with my xml file 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>
Now:
setContentView(R.layout.tester1);
Will not work for some reason but
setContentView(GameView(this));
Works, any help please
Sorry if this seems easy, I'm quite new and still getting my head around it. Thank you for reading.