Question

I have a problem....

First, I go to main page. After I click MASUK button, I hope I can go to BOARD VIEW which have landscape orientation. But I got error.

public class MainActivity extends Activity {
Button masuk;

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

    masuk = (Button) findViewById(R.id.button_masuk);
    masukClicked();
 }

 void masukClicked() {
    masuk.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(MainActivity.this, Board.class);
            startActivity(intent);
        }
    });
 }
}

BOARD VIEW in this class

public class Board extends Activity{

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

RESOURCES :

enter image description here

ANDROID MANIFEST :

   <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.snakeladder"
    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" >
        <activity
            android:name="com.example.snakeladder.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>
        <activity
            android:name=".Board" >
        </activity>
    </application>

</manifest>

I want to go to landscape view after click button. The landscape view is inside layout-land folder

Was it helpful?

Solution

<activity
            android:name=".Board"
android:screenOrientation="landscape" >
        </activity>

add this code it'll do the work

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top