【问题标题】:Replace row of a listview with animation Android用动画Android替换列表视图的行
【发布时间】:2013-07-15 10:29:12
【问题描述】:

您能否建议我有关如何在“长项目单击”后用动画替换列表视图的一行的想法。当您“长按”推文时,我想做类似 Twitter 的应用程序。 谢谢。

【问题讨论】:

  • replace 意思是删除?
  • 不,动态更改列表视图项
  • graphics-geek.blogspot.in 列表视图的动画。博主是安卓开发者@google。视频+代码。
  • 你确定你的链接吗?
  • 是的。我贴错了,现在编辑了。检查一下

标签: android listview animation


【解决方案1】:

首先,你应该得到你想要的物品:

int visiblePosition = yourListView.getFirstVisiblePosition();
View v = yourListView.getChildAt(itemIndex - visiblePosition);

其次,在item上开始动画:

Animation anim = AnimationUtils.loadAnimation(
                 GoTransitApp.this, android.R.anim.slide_out_right
             );
anim.setDuration(500);
v.startAnimation(anim );

希望对您有所帮助!

参考: Android – Update single item in ListView

animation

【讨论】:

  • 谢谢,但是正如我解释的那样,旨在替换行中当前布局的布局呢?我想在 Twitter 应用中对推文执行“长按”操作。
  • 你的意思是像 twitter 这样的新布局吗?您可以将布局放在现有布局的顶部并使其可见性=消失,然后在长按发生时使其可见性=可见
  • AlphaAnimation alphaAnimation = new AlphaAnimation(0.2f, 1.0f);在您的新布局上启动此动画。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-07-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-06
  • 2012-05-04
  • 1970-01-01
相关资源
最近更新 更多