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