我有问题......
首先,我转到主页。点击 MASUK按钮后,我希望我可以转到 BOARD VIEW,它有横向。 但我收到了错误 。
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
public class Board extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.board);
}
}
资源:
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>
我想点击按钮后进入横向视图。横向视图位于layout-land文件夹
内答案 0 :(得分:1)
<activity
android:name=".Board"
android:screenOrientation="landscape" >
</activity>
添加此代码,它将完成工作