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?
Thanks in advance.
It sounds like you want to use an transition animation between two ListView fragments. In order to do this, call setTransition()
before committing the fragment transaction.
An answer to a related question gives more detailed information.
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);
}
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));
Step 3:
Create anim folder under the res folder,and add the needed .xml files.
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;
Refer this site for more details:http://velmuruganandroidcoding.blogspot.in/2014/08/listview-item-animation-in-android.html