0

Well im doing the main activity for a true false game. No errors on neither files( xml, java ,manifest ) but when i debugged it ( on a real phone no virtual, galaxy note 2 ) nothing shows on the screen ,no buttons ,no text views and for sure no images . Also i want my activity to be locked to landscape always how is it possible?

Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.truefalsegame"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        android:debuggable="true" >
        <activity
            android:name="com.example.truefalsegame.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Java:

package com.example.truefalsegame;

import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {

    Button exit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        exit= (Button) findViewById(R.id.button2);
        exit.setOnClickListener((OnClickListener) this);


    }

    public void onClick(View v) {

        switch (v.getId()) {
        case R.id.button2:finish();
        System.exit(0);
        break;
        }
    }
}

XML main activity:

<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="wrap_content"
    android:gravity="center"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:gravity="center"
        android:text="@string/title"
        android:textColor="@color/blue"
        android:textSize="27sp" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:src="@drawable/book" />

    <Button
        android:id="@+id/button1"
        style="@style/btnStyleShakespeare"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textView1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="34dp"
        android:background="@color/blue"
        android:text="@string/new_game" />

    <Button
        android:id="@+id/button2"
        style="@style/btnStyleShakespeare"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/imageView1"
        android:layout_alignLeft="@+id/button1"
        android:layout_alignRight="@+id/button1"
        android:background="@color/blue"
        android:text="@string/exit" />

</RelativeLayout>
Giorgos Neokleous
  • 1,709
  • 1
  • 14
  • 25

1 Answers1

-1

in AndroidMenifest.xml

 <activity
        android:name="Activty"
        android:screenOrientation="portrait"
         >

this should work :)

Amit
  • 391
  • 3
  • 15
  • 2
    Setting it to Portrait won't work as the OP is asking, and I quote _"i want my activity to be locked to landscape"_. He wants Landscape mode - so you'll need `android:screenOrientation="landscape"`. Also, he's getting a blank screen, but your answer does not address this point. – ChuongPham Apr 10 '14 at 14:21
  • sorry i was on hurry and made mistake i was reading it landscape but was writing portrait right and is android:screenOrientation="landscape" :) if orientation is fixed then i think you will not have this blanck screen issue but if you still this then please let know – Amit Apr 11 '14 at 04:35
  • it worked ? if not then please explain your issue :) – Amit Apr 14 '14 at 06:04