Android 屏幕方向和碎片

Android 屏幕方向和碎片,android,android-layout,fragment,android-orientation,Android,Android Layout,Fragment,Android Orientation,有件事真的让我抓狂。屏幕的布局没有正确地从陆地变为纵向 布局文件夹中有两个文件夹用于处理方向信息和其中的.xml文件,如下所示: layout\main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" andr

有件事真的让我抓狂。屏幕的布局没有正确地从陆地变为纵向

布局文件夹中有两个文件夹用于处理方向信息和其中的.xml文件,如下所示:

layout\main.xml  

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

<fragment
    android:id="@+id/menu"
    android:name="br.trebew.odonto.MenuData"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

<fragment
    android:id="@+id/princ"
    android:name="br.trebew.odonto.FragList"    
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

</LinearLayout>
如果屏幕是纵向的,则旋转时会正确地改变

问题恰恰相反。如果屏幕是陆地,则旋转不会改变布局。事实上,它正确地调用了onCreate方法,但布局不会更改为纵向=/


任何人都会知道原因。

问题可能是,对于正常大小的屏幕,您的肖像位于文件夹中,而对于大屏幕,您的风景位于文件夹中。也许您可以将layout large land更改为layout land(如果您的设备具有普通屏幕),或者将layout更改为layout large(如果您的设备具有大屏幕),然后查看它是否有任何作用。(注意:即使它有一个大屏幕,将它放在布局和布局栏中仍然可以工作)。

好吧。。。我已经像你说的那样更改了文件夹名称(两种组合),但仍然不起作用!和以前一样=/我不知道这是否意味着什么,但我只在虚拟设备上进行了测试。Android 2.3.3,API级别10,屏幕大小:720x960,密度:240。
layout-large-land\main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="290dp" 
    android:layout_height="fill_parent">

<fragment
    android:id="@+id/menu"
    android:name="br.trebew.odonto.MenuData"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

<fragment
    android:id="@+id/princ"
    android:name="br.trebew.odonto.FragList"    
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

</LinearLayout>

<fragment 
    android:id="@+id/fdetalhe"
    android:name="br.trebew.odonto.DetalheFragment"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

</LinearLayout>
public class OdontO extends FragmentActivity implements OnDateChangeListener, OnAgendaItemClickListener {

FragList fList;
MenuData mData;
DetalheFragment frag_detalhe;

private boolean detalhesInLine;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);   

    Log.i("LayoutOr", "Entrou no onCreate OdontO");

    mData = (MenuData) getSupportFragmentManager().findFragmentById(R.id.menu);
    fList = (FragList) getSupportFragmentManager().findFragmentById(R.id.princ);  

    frag_detalhe = (DetalheFragment) getSupportFragmentManager().findFragmentById(R.id.fdetalhe);
    detalhesInLine = (frag_detalhe != null && 
            (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE));
    if (detalhesInLine) {
        fList.enablePersistentSelection();
    }
    else if (frag_detalhe != null) {
        frag_detalhe.getView().setVisibility(View.GONE);
    }
}