Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 1.25 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Adding animation to a List View in Android
  2. set = new AnimationSet(true);
  3.  
  4.     animation = new AlphaAnimation(0.0f, 1.0f);
  5.     animation.setDuration(50);
  6.     set.addAnimation(animation);
  7.  
  8.     animation = new TranslateAnimation(
  9.         Animation.RELATIVE_TO_SELF, 0.0f,Animation.RELATIVE_TO_SELF, 0.0f,
  10.         Animation.RELATIVE_TO_SELF, -1.0f,Animation.RELATIVE_TO_SELF, 0.0f
  11.     );
  12.     animation.setDuration(150);
  13.     set.addAnimation(animation);
  14.  
  15.     LayoutAnimationController controller = new LayoutAnimationController(set, 1.0f);
  16.     l.setLayoutAnimation(controller);
  17.     l.setAdapter(listAdaptor);
  18.        
  19. l.startLayoutAnimation();
  20.        
  21. View v = convertView;
  22.  
  23.         if (v == null) {
  24.             LayoutInflater vi = (LayoutInflater) getActivity()
  25.                     .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  26.             v = vi.inflate(R.layout.simple_list_item_1, null);
  27.         }
  28.  
  29.         ListData o = list.get(position);
  30.         TextView tt = (TextView) v.findViewById(R.id.toptext);
  31.  
  32.         tt.setText(o.content);
  33.  
  34.         Log.d("ListTest", "Position : "+position);
  35.        if(flag == false) {
  36.         Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_top_to_bottom);
  37.         v.startAnimation(animation);}
  38.         return v;
  39.     }