Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to make translation animation for each listview items
    primarykey
    data
    text
    <p>i have a listview with override getView method to populate it. now, i want to make each item of the list to animate or moving from the right side of the screen to the left side where the item should normally appear.</p> <p>the animation of each item should not start at the same time, it must delay for couple ms before the other items moving...</p> <p>well, this is my adapter class:</p> <pre><code>public class MyAdapter extends ArrayAdapter&lt;String&gt;{ private Context context; private String[] info; public MyAdapter(Context context, int resource, String[] objects) { super(context, resource, objects); // TODO Auto-generated constructor stub this.context = context; this.info = objects; } protected class RowViewHolder { public TextView text1; public CheckBox cb; public String ss; } @Override public View getView(int pos, View inView, ViewGroup parent) { View vix = inView; RowViewHolder holder; if (vix == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); vix = inflater.inflate(R.layout.check_list, null); } holder = new RowViewHolder(); holder.text1 = (TextView) vix.findViewById(R.id.info_group); holder.text1.setText(info[pos]); holder.ss = info[pos]; holder.cb = (CheckBox) vix.findViewById(R.id.check); holder.cb.setTag(holder.ss); holder.cb.setOnCheckedChangeListener(CbListen); vix.setTag(holder); return vix; } private OnCheckedChangeListener CbListen = new OnCheckedChangeListener(){ @Override public void onCheckedChanged(CompoundButton com, boolean pool) { // TODO Auto-generated method stub String state = (com.getTag()).toString(); if(com.isChecked()){ System.out.println(state+" CHECKED"); }else{ System.out.println(state+" UNCHECKED"); } } }; } </code></pre> <p>any idea? :)</p> <p><strong>UPDATE</strong></p> <p>Well, surely it is! LOL :p</p> <p>just download those ApiDemos "like what have Farhan said" and you guys will find some kind like LayoutAnimation2 sample at the package view.</p> <p>there, each items of the list is being animated to populate downward by translate-animation while the alpha is changing respectively.</p> <p>here's what i do for my case:</p> <pre><code>AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(500); set.addAnimation(animation); animation = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 50.0f,Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,Animation.RELATIVE_TO_SELF, 0.0f ); animation.setDuration(1000); set.addAnimation(animation); LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f); group_list.setLayoutAnimation(controller); </code></pre> <p>i put this below my setAdapter() function, you guys can make it look more cozy with accelerate-decelerate etc effects.</p> <p>:p</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload