<activity android:name=".MainActivity" android:label="@string/title_activity_main" android:screenOrientation="landscape">
<activity android:name=".MainActivity" android:label="@string/title_activity_main" android:screenOrientation="portrait" >
<activity android:name=".MainActivity" android:label="@string/title_activity_main">
<activity android:name=".MainActivity" android:label="@string/title_activity_main"> <activity android:name=".DetailActivity" android:label="@string/title_activity_main" android:screenOrientation="landscape"> <activity android:name=".ViewActivity" android:label="@string/title_activity_main" android:screenOrientation="portrait">
<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" > <TextView android:id="@+id/txtResult" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_marginTop="130dp" android:text="Result" android:gravity="center_horizontal" android:textAppearance="?android:attr/textAppearanceMedium" /> </RelativeLayout>
package com.myapp; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.widget.TextView; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final TextView result = (TextView) findViewById(R.id.txtResult); int mode = getResources().getConfiguration().orientation; if (mode == 1) { result.setText("Current Portrait"); } else { result.setText("Current Landscape"); } } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } }
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท