Android的,是否有可能把两个不同的活动中使用片段平板电脑屏幕?有可能、平板、片段、电脑屏幕

2023-09-12 06:03:01 作者:﹏風流∨成癮Ο

根据我的研究紧靠片段,片段使用时,我们的标题/描述基于内容,如书籍,杂志等。

According to my research abut fragment, fragments are using when we have Title/description based contents, such as books, magazine, etc.

有些项目不是标题/描述基地。在这种情况下,我们可以使用的片段? 例如,假设我们有10屏平板,我想告诉我的内屏幕的应用4个不同的活动,而在手机用户提供点击菜单上可以看到它们。

Some projects are not title/description base. In this situation can we use fragments? for example, assume that we have 10" screen tablet and I want to show 4 different activity of my application inside screen while in handsets user with clicking on menus can see them.

是有可能做到这一点?谢谢

is it possible to do this? Thanks

推荐答案

Yups,你可以让你的屏幕上尽可能多的活动,只要你想使用的片段的。

Yups, you can make as many activity on your screen as you want using Fragments.

片段是由谷歌开发的平板电脑的屏幕尺寸很大,我们可以容纳在一个屏幕上更多的功能。所有这些工作都由FragmentManager完成。你可以用你想要的任何图案尽可能多的片段视图中的XML布局。然后关联所有以一个单独的活动。活性也彼此之间进行通信。更可以在下面的例子找到。

Fragments was developed by google as the screen size of tablet is large and we can accommodate more functionality in one screen. All work is done by FragmentManager. You can make an XML layout with as many fragment view you want in any pattern. Then associate all the view to an individual activity. Activity can communicate between each other also. More you can find in following examples.

http://www.vogella.com/articles/Android/article。 HTML#fragments_tutorial HTTP://android-developers.blogspot。在/ 2011/02 / Android的30片段,api.html http://mobile.tutsplus.com/tutorials/android/android-sdk_fragments / http://www.vogella.com/articles/Android/article.html#fragments_tutorial http://android-developers.blogspot.in/2011/02/android-30-fragments-api.html http://mobile.tutsplus.com/tutorials/android/android-sdk_fragments/

修改

您需要做的是利用下面的函数得到的宽度和高度。

What you need to do is get the width and height using following function.

@Override
public void onCreate(Bundle icicle) {
    WindowManager w = getWindowManager();
    Display d = w.getDefaultDisplay();
    int width = d.getWidth();
    int height = d.getHeight();

请不同的布局屏幕的不同的维度。现在,如果保持其他回路来决定哪些布局使用设置的setContentView(R.id.layoutfor10inchtable)等。

Make different layout for different dimension of screen. Now keep if else loop to decide which layout to be set using setContentView(R.id.layoutfor10inchtable) etc.

有关配置更改,做一个布尔变量说permitConfigurationChange,当你设置视图,你也可以将此变量设置为true或false中的if else循环。

For configuration change, make one boolean variable say permitConfigurationChange and when you are setting the view, you can also set this variable to true or false in if else loop.

的倍率onConfigurationChange方法。如果在检查如果(permitConfigurationChange ==假)回报;

The override onConfigurationChange method. In if check if (permitConfigurationChange == false) return;

部分的设计布局,你需要看的教程,他们会为您提供所有的细节。

Design part for layout, you need to see the tutorials, they will provide you all the details.