在活动滚动片段(无viewpager) [英] Scrollable Fragments within Activity (no viewpager)

查看:137
本文介绍了在活动滚动片段(无viewpager)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提出一个Android的应用程序,它具有以下几个基本的布局:

I would like to make an Android-app which has the following basic layout:

活动应持有几个片段(其中都有着不同的布局),该片段可接或者滚动向左或向右(在黑色边框的区域在图像中)或pressing的previous /下一个按钮。

The activity should hold several fragments (which all have different layouts), the fragments can be accessed by either scrolling left or right (in the black bordered area in the image) or by pressing the previous/next button.

该片段的布局包含输入字段时,无论是下一个按钮是pressed,或向右滑动执行应进行验证。如果输入字段是空的,不应该被显示的下一个片段。

The layout of the fragments contain input fields which should be validated when either the next button is pressed, or a swipe to the right is performed. If the input field is empty, the next fragment should not be displayed.

我想这样做,使用一个viewpager,使用一些变通方法不属于pretty的这只,所以我试图找到一种不同的方法。

I tried doing that using a viewpager, this only works using some workarounds which aren't pretty, so I am trying to find a different approach.

所以我的问题是:什么是实现上述不使用viewpager功能的最佳方法是什么?也许将在片段的姿态监听器和排序的手动刷卡呢?

So my question is: What would be the best way to implement the functionality described above without using a viewpager? Maybe putting a gesture listener on the fragments and swiping them sort of manually?

帮助将不胜AP preciated!

Help would be greatly appreciated!

推荐答案

有一个向导式的用户界面的按钮是好的,而且有至少一个磁带库在那里为。我一般不同意你关于刷卡事件的方法。

Having a wizard-style UI with the buttons is fine, and there's at least one library out there for that. I generally disagree with your approach regarding the swipe events.

事实证明,验证是非常棘手的。

It turns out that validation is very tricky

我不知道你的意思。

恕我直言,最简单的办法是使用 ViewPager ,在那里你不添加下一步页面,直到验证条件得到满足,并删除下一步如果验证标准是页则未得到满足(例如,用户清除字段)。您将需要使用自定义的 PagerAdapter 这一点,或者的我的 ArrayPagerAdapter ,如添加/删除页面从股市适配器不工作那么好(虽然他们的可以的是确定只是在一端...)。

IMHO, the simplest solution is to use a ViewPager, where you do not add the "Next" page until the validation criteria are met, and you remove the "Next" page if the validation criteria are then un-met (e.g., user clears the field). You will need to use a custom PagerAdapter for this, or perhaps my ArrayPagerAdapter, as adding/removing pages from the stock adapters does not work all that well (though they may be OK for just at the one end...).

不过,再一次,这是我觉得你的UX是不是一个好。假设你有向导四种可能的总页数,这里命名为A,B,C和D的用户开始对A,填写你的领域,进入到B,填写你的领域,进入到C,填写您的场,前进到研发,可以追溯到B,并清除B的场(或以其他方式使其无效)。根据您的流量,用户不能再前进到C,直到B的字段填写。而从通过下一步按钮前进,具有被禁用,直到B的形式验证是完全合理的,用户很可能看到过(例如,桌面操作系统向导)的行为的立场。但用户并不一定要明白,下一步按钮,轻扫在逻辑上是一样的东西,因为用户习惯于刷卡到任何他们想要的,一旦他们意识到,他们可以刷卡那里。因此,如果我这样做,我会用直线向导用户界面去,SANS刷卡事件。

But, again, this is where I feel that your UX is not a good one. Suppose you have four total possible pages in the wizard, here named A, B, C, and D. The user starts on A, fills in your field, advances to B, fills in your field, advances to C, fills in your field, advances to D, goes back to B, and clears B's field (or otherwise invalidates it). According to your flow, the user cannot advance again to C until B's field is filled out. And from the standpoint of advancing via a "Next" button, having that be disabled until B's form validates is perfectly reasonable, and users may well have seen that behavior before (e.g., desktop OS wizards). But the user is not necessarily going to understand that the Next button and a swipe are logically the same thing, as users are used to swiping to whatever they want, once they realize that they can swipe there. Hence, if I were doing this, I'd go with a straight-up wizard UI, sans swipe events.

这篇关于在活动滚动片段(无viewpager)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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