0

嗨,我已经创建了两个片段在单一布局。不同的设计肖像和风景模式在android

在布局土地:

片段需要水平显示。

在布局端口: 片段需要垂直显示。

现在我有上运行肖像模式应用装置竖直地显示所述片段。 现在我不得不将它们旋转到横向模式意味着仅仅垂直显示片段。

同时我要运行上横向模式应用程序装置上显示该片段horizo​​ntally.now我不得不这些到纵向模式是指水平显示所述片段旋转。

但我希望以显示输出等:

我有上运行肖像模式应用装置竖直地显示所述片段。 现在我必须将这些旋转到横向模式意味着水平显示片段。

同时我要运行上横向模式应用程序装置上显示该片段horizo​​ntally.now我不得不这些到纵向模式是指垂直地显示所述片段旋转。

我该怎么办?

为什么我得到的结果一样above.please给我任何建议。

编辑:

布局土地:fragment.xml之:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" 
android:id="@+id/_listDetails" 

> 
    <ImageView 
     android:id="@+id/refresh" 
     android:layout_width="wrap_content" 
     android:layout_height="45dp" 

     android:layout_gravity="center_vertical" 
     android:layout_toLeftOf="@+id/pos" 
     android:src="@drawable/ref_off" /> 
<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:layout_below="@+id/layout" 
android:background="#414042" 
android:orientation="horizontal" > 

<fragment 
    android:id="@+id/activity_main" 
    android:name="com.notch.notchbolly.MainActivity" 
    android:layout_width="0px" 
    android:layout_height="match_parent" 
    android:layout_weight="0.83" 

    /> 
    <View 
    android:layout_width="2dp" 
    android:layout_height="fill_parent" 
    android:background="#FFFFFF" 
    /> 
<fragment 
    android:id="@+id/subcate" 
    android:name="com.notch.notchbolly.SubCate" 
    android:layout_width="0px" 
    android:layout_height="match_parent" 
    android:layout_weight="1" /> 
    </LinearLayout> 
    </RelativeLayout> 

布局端口:fragment.xml之:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" 
android:id="@+id/_listDetails" 

> 
    <ImageView 
     android:id="@+id/refresh" 
     android:layout_width="wrap_content" 
     android:layout_height="45dp" 

     android:layout_gravity="center_vertical" 
     android:layout_toLeftOf="@+id/pos" 
     android:src="@drawable/ref_off" /> 
<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:layout_below="@+id/layout" 
android:background="#414042" 
android:id="@+id/orien" 
android:orientation="vertical" 
> 

<fragment 
    android:id="@+id/activity_main" 
    android:name="com.notch.notchbolly.MainActivity" 
    android:layout_width="fill_parent" 
    android:layout_height="200dp" 

    /> 
<View 
    android:layout_width="fill_parent" 
    android:layout_height="3dp" 
    android:background="#FF0000" 
    /> 
<fragment 
    android:id="@+id/subcate" 
    android:name="com.notch.notchbolly.SubCate" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    /> 


    </LinearLayout> 
    </RelativeLayout> 

这是我AndroidListFragmentActivity :

public class AndroidListFragmentActivity extends FragmentActivity { 


     /** Called when the activity is first created. */ 
    @Override 
     public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.fragment); 

    ImageView refresh = (ImageView) findViewById(R.id.refresh); 
     refresh.setOnClickListener(new OnClickListener() { 
      public void onClick(View v) { 

       Intent in = new Intent(AndroidListFragmentActivity.this, AndroidListFragmentActivity.class); 
       startActivity(in); 
       } 
      }); 



       } 
      @Override 
      public void onConfigurationChanged (Configuration newConfig) 
       { 
       super.onConfigurationChanged(newConfig); 

     } 

     } 
+0

https://www.youtube.com/watch?v=3FMn4FEv12M检查此视频。 – TheFlash 2013-05-09 11:17:43

回答

1

从清单文件中的活动声明中取出android:configChanges="orientation"

+0

我已经删除了这些工作完美...但采取加载时间...我需要显示不同的用户界面,而不需要加载时间,当方向改变.. – user2218667 2013-05-09 11:36:01

+0

当方向改变时,布局被破坏和重新创建新方向的资源。所以它需要很少的加载时间 – 2013-05-09 11:45:00

+0

不......这里我的活动需要太多的时间...在这里我必须改变方向意味着整个活动再次加载..我不需要像这些。我需要显示没有加载时间 – user2218667 2013-05-09 11:50:51