展会信息港展会大全

android实现Listview的每一项按顺序水平移动到其显示位置的动画
来源:互联网   发布日期:2015-11-26 11:02:46   浏览:1908次  

导读: 当开始显示listview的时候,让每一项按顺序从屏幕右边滑倒左边。adapter代码如下public class MyAdapter extends ArrayAdapterString{private Context context;private String[] info;public MyAda......

当开始显示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");

}

}

};

}

试下这段代码:

`

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);

赞助本站

人工智能实验室

相关热词: 水平移动 动画

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港