Android-android如何实现Listview的每一项按顺序水平移动到其显示位置的动画
当开始显示listview的时候,让每一项按顺序从屏幕右边滑倒左边。
adapter代码如下
public class MyAdapter extends ArrayAdapter<String>{
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");
}
}
};
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试下这段代码:
`
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);
`