我有一个项目,实现一个应用程序的平板电脑版本。此应用程序只有纵向模式,没有横向模式支持。因此,我的方法是在平板电脑上实现这两种方法。
然而,你们都知道android有不同类型的设备和android版本。如何确保我的平板电脑应用程序可以在所有平板电脑设备上运行。还有UI,在平板电脑上做什么是最好的做法?如何确保我的应用程序布局适合所有设备?什么样的UI框架对于开发android平板电脑是有用的?
发布于 2013-01-18 23:32:05
你必须使用片段。因此,您的应用程序可能如下所示:

layout/main.xml:
<LinearLayout
android:id="@+id/handset"
[...]
>
</LinearLayout>layout-large/sw400dp:
<LinearLayout
[...]
>
<fragment android:name="com.bla.bla.FirstFragment"
android:id="@+id/first_fragment"
[...]
/>
<fragment android:name="com.bla.bla.SecondFragment"
android:id="@+id/second_fragment"
[...]
/>
</LinearLayout>现在,
中检查此信息
if (findViewById(R.id.handset) != null) {
// it's a handset device and you can add a Fragment to this View
}
FirstFragment firstFragment = new FirstFragment();
getSupportFragmentManager().beginTransaction().add(R.id.handset, firstFragment).commit();R.id.handset返回null,则它是tablet,在这种情况下,静态添加的片段将由它们的Fragments类处理。https://stackoverflow.com/questions/14400968
复制相似问题