Listview item animation in android
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); } |
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; |
DOWNLOAD FULL SOURCE CODE
No comments:
Post a Comment