滑动式线性/相对布局 [英] Swipable Linear/Relative Layout

查看:190
本文介绍了滑动式线性/相对布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在android系统相对初学者。我试图建立一个类似的应用程序,如下图所示的计算器。我现在面临的问题是关于决定如何刷卡计算器权的科学部分,如图的形象。这当然不是一个 ViewPager ,是吗?我不能断定如何构建此功能。我将使用 RelativeLayout的并使用自己的Java code,使其可滑动。如果是的话怎么样?请帮我关于如何使计算器的科学部分可滑动

I am relatively a beginner in android. I was trying to build a similar app as the calculator shown below. The problem that I am facing is regarding deciding how to swipe the scientific part of the calculator to the right as shown in the image. It is certainly not a ViewPager, or is it? I cannot conclude how to build this feature. Shall I use a RelativeLayout and use my own java code to make it swipable. If so then how? Please help me regarding how to make the Scientific part of the calculator swipable?

在这里输入的形象描述

推荐答案

如果你不想使用 ViewPager ,你可以使用的 ViewFlipper

If you do not want to use ViewPager, you can use ViewFlipper.

您可以使用 ViewPager 。您应该创建两个片段,例如 BasicButtonsFragment ScientificButtonsFragment 。那么你应该创建一个 FragmentPagerAdapter

You can use ViewPager. You should create two fragments, for example BasicButtonsFragment and ScientificButtonsFragment. Then you should create a FragmentPagerAdapter.

public static class MyAdapter extends FragmentPagerAdapter {
    public MyAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public int getCount() {
        return 2;
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 0)
            return BasicButtonsFragment.newInstace();
        return ScientificButtonsFragment.newInstance();
    }
}

Finnaly,该适配器设置为你的 ViewPager

这篇关于滑动式线性/相对布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆