通过47degree SwipeListView:编程刷卡第一项: [英] SwipeListView by 47degree: swipe first item programmatically:
问题描述
我想刷卡上在 SwipeListView 中的第一项活动
启动以表明 SwipeListView
是滑动展示给用户。
I would like to swipe the first item on the SwipeListView on Activity
start up to show the user that the SwipeListView
is swipe-able.
我如何使用该UI元素编程方式执行此操作?
How can I perform this action programmatically with this UI element?
更新:
我试图用
swipeListView.openAnimate(position)
这是在这里提出的答案,但即使我用数据填充项适配器...当我调试,并达到这个code节swipeListView不会看到它的项目,由于某种原因失败 NullPointerException异常
。
that was proposed here in the answer, but for some reason even after I populate the adapter with data-items... when I debug and reach this code section the swipeListView doesn't see item in it, and fails with NullPointerException
.
UPDATE2:好吧,我意识到有在适配器没有项目,因为它尚未的onCreate
创建的,让我感动的原因这code至方法:
UPDATE2: Well, I realized that the reason there were no items in the adapter because it's not yet created in onCreate
, so I moved this code to method:
public void onWindowFocusChanged(boolean hasFocus){}
我的活动,现在它运行,但仍然无法在 SwipeListView
库的方法如下:
private void resetCell() {
if (downPosition != ListView.INVALID_POSITION) {
if (swipeCurrentAction == SwipeListView.SWIPE_ACTION_CHOICE) {
backView.setVisibility(View.VISIBLE);
}
frontView.setClickable(opened.get(downPosition));
frontView.setLongClickable(opened.get(downPosition));
frontView = null;
backView = null;
downPosition = ListView.INVALID_POSITION;
}
}
这样做的原因是,当这种方法运行前视图
对象从不设置以及它为空,也有人遇到过这个问题?
The reason for this is that when this method is running the frontView
object is never set and those it null, have some one encountered this error?
先谢谢了。
推荐答案
其实我已经去了,重新在库中使用的动画只是为了展示的实例,所以我所做的是:
I have actually went and recreated the used animation in the library just for the instance of the Showcase, so what I did was:
private void generateRevealAnimate(final View view) {
animate(view)
.translationX(-520)
.setDuration(500)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {}
});
}
private void generateCloseAnimate(final View view) {
animate(view)
.translationX(0)
.setDuration(500)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {}
});
}
然后只需运行它们一个接一个的所需的视图:
And then just run them one after another on the desired view:
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run()
{
generateRevealAnimate(firstFrontView);
handler.postDelayed(new Runnable() {
@Override
public void run()
{
generateCloseAnimate(firstFrontView);
}
}, 1400);
}
}, 1400);
这篇关于通过47degree SwipeListView:编程刷卡第一项:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!