ListView的动画 [英] ListView animation

查看:118
本文介绍了ListView的动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类别的ListView(主列表)。在这个列表中的每个类别都有子类别列表(多个级别)。当任何主列表项被点击时,相同的列表重新填充与所选项目的子类别清单。我想申请动画这一功能,即被点击主列表项时,列表遍历向左移出屏幕,并在同一时间与重新填充数据相同的列表从右用武之地。

I have a ListView(main list) of categories. Each category in this list has a list of subcategories(multiple levels). When any of the main list item is clicked, the same list is repopulated with the subcategory list of the selected item. I want to apply animation to this functionality i.e. when main list item is clicked, the list traverses to the left out of the screen and at the same time the same list with repopulated data comes in from right.

因此​​,谁能告诉我,请,如果有可能以任何方式同时适用两个不同的动画同样的看法?

So can anyone tell me please if it is possible in any way to apply two different animations to the same view at the same time?

一个我能想到的是有一个虚拟列表,并保持两个列表视图之间的数据的变通方法。是否有任何其他解决办法?

One of the workaround I could think of is having a dummy list and maintaining the data between the two listViews. Is there any other workaround?

先谢谢了。

推荐答案

这是示例code为创建lisview和列表视图项添加动画。
请按照简单的步骤来创建列表视图项动画。
步骤1:
创建列表视图,然后创建简单的ArrayList中的列表视图设置,在到ArrayList中添加值。

This is sample code for create lisview and add the animation in the listview items. Please follow the simple steps to create the listview items animation. Step 1: Create the listview and then create simple ArrayList to set in the listview,add values in to the Arraylist.

ArrayList<String> items=new  ArrayList<>();
listView=(ListView)findViewById(R.id.listview);
for(int i=0;i<100;i++){
items.add("Item "+i);
}

步骤2:
创建视图使用baseAdapter设置项目到列表视图。

Step 2: Create view to set the items into the listview using the baseAdapter.

LayoutInflater inflater = getLayoutInflater();
view = inflater.inflate(R.layout.list_adapter, parent, false);
TextView itemName=(TextView)view.findViewById(R.id.itemName);
itemName.setText(items.get(position));

步骤3:
创建res文件夹下的动画文件夹,并添加所需的.xml文件。

Step 3: Create anim folder under the res folder,and add the needed .xml files.

步骤4:
最后,创建动画,并设置在ListView适配器观看动画。

Step 4: Finally,Create the animation and set the animation in the listview adapter view.

Animation animation = null;
animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.wave);
animation.setDuration(200);
view.startAnimation(animation);
animation = null;

请参阅本网站的更多details:http://velmuruganandroidcoding.blogspot.in/2014/08/listview-item-animation-in-android.html

Refer this site for more details:http://velmuruganandroidcoding.blogspot.in/2014/08/listview-item-animation-in-android.html

这篇关于ListView的动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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