Android 平板电脑和设备的屏幕方向

Android 平板电脑和设备的屏幕方向,android,Android,我对平板电脑和设备使用相同的代码,这是我的问题,当在两个方向移动时,它应该加载列表视图,在纵向平板电脑时,它需要加载列表视图,然后在横向平板电脑时,它应该加载gridview 谢谢 我用过这个代码,任何人都可以帮我 Configuration config = getResources().getConfiguration(); if((config.screenLayout & Configuration.ORIENTATION_LANDSCA

我对平板电脑和设备使用相同的代码,这是我的问题,当在两个方向移动时,它应该加载列表视图,在纵向平板电脑时,它需要加载列表视图,然后在横向平板电脑时,它应该加载gridview

谢谢

我用过这个代码,任何人都可以帮我

 Configuration config = getResources().getConfiguration();
                    if((config.screenLayout & Configuration.ORIENTATION_LANDSCAPE) ==  
                        Configuration.SCREENLAYOUT_SIZE_XLARGE)); 
                    {
                        this.gridView();    
                    }else{
                        this.listview();
                    }

如果在布局中使用xml,则只需创建不同的xml文件,并将它们放置在具有适当配置限定符的布局文件夹中。请参阅此以了解详细信息

对于您,您将使用以下文件夹:

res/layout/my_layout.xml             // layout for normal screen size ("default"). Listview here
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation. Gallery here
请记住,如果这些文件夹不存在,则需要创建它们


在代码中,如果调用
setContentView(R.id.my_layout)
,android将使用适当的布局。然后,您可以执行一个
findViewById()
调用,对于未使用的布局视图,该调用应返回null。您可以在ListView和GridView上执行
findViewById()
。根据哪个视图返回null,您可以适当地设置成员(this.gridView或this.listView)。

在您的布局设计中,哪个控件使用????gridView或ListView?????在layout Xlarge land中,我使用gridView,然后在layout Xlarge port中,我使用ListView,在普通布局中,我使用ListView,我创建了此布局。。我想我提供的信息足以让你写出if-else语句