为什么你想在你的方向改变时开始一个新的活动? 最好为不同的配置提供不同的资源!或者在1 Activity中使用Fragments。
更多信息可以在这里找到:
编辑: 您只需创建,再现本身的方向改变一个活动。因此,请删除您在AndroidManifest.xml中的任何configChanges="screenSize..."
。 在活动的xml文件中,您可以链接到另一个片段。 同样,有关这方面的更多信息可以在上面的链接中找到。
MyActivity.java
public class MyActivity extends Activity
{
@Override
public void onCreate(Bundle cycle)
{
super.onCreate(cycle);
this.setContentView(R.layout.myactivity);
}
}
RES /布局/ myactivity.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
class="com.example.myapp.fragments.TimeFrameGraphFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
而RES /布局,土地/ myactivity.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
class="com.example.myapp.fragments.AllDataGraphFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
请参阅此链接 - http://stackoverflow.com/questions/12983792/how-to-switch-to-other-activity-at-orientation-change-and-then-back-again – NarendraJi