ListView飞入加载item及滑动删除item
现在已经是10月28号晚上近11点,原本打算是11点就睡觉的,看样子是不行了,因为还没有洗澡,明天又要上班了。弄完这个demo,有点小兴奋,一会洗澡看比赛。
好吧,我承认我是个比较关注时事的程序员,所以我的微博上面转发的时事微博要远远多于关于技术微博。http://weibo.com/u/1832139851,这是我的微博。感兴趣的朋友可以互粉一下。这两天,宁波人民为了自己的利益走向街头,这不是今年的第一起因为环境安全问题引发的群体事件,而政府的举措还是愚蠢之极,让人感到愤慨,当然,他们并不是愚蠢,他们只是不能接受人民从臣民转换为公民。借用一句”不明真相之际,鸡蛋和石头的较量中,我永远站在鸡蛋一边”来表明自己的态度。祝福宁波人民。
好吧,下面进入正题:
在listview中,可以加入动画使其效果更炫一点。这个demo修改至网上下载的一个版本,改动还算比较大。因为有动画,所以不好上演示图,不知道看到博客的各位有什么可以生成gif的工具,希望能够推荐一下。
因为是修改的别人的代码,他的demo中item数据的意义,我也不是太明白,先上一张图片:

进入程序时,呈现飞入效果。从左向右滑动item时,删除该item。
下面进入代码:
class ViewHolder {public TextView maxValue;public Button del_btn;public TextView how_time;public TextView last_time;public TextView avgValue;public ImageView image;public boolean isVisible = true;}public class MyAdapter extends BaseAdapter { private Context mContext;private MyAdapter(Context context) {mContext = context;}public int getCount() {return mData.size();}public Object getItem(int position) {return position;}public long getItemId(int position) {return position;}public View getView(final int position, View convertView, ViewGroup parent) {ViewHolder holder = null;if(convertView == null) {holder = new ViewHolder();LayoutInflater inflater = LayoutInflater.from(mContext);convertView = inflater.inflate(R.layout.record_info, null);holder.del_btn = (Button) convertView.findViewById(R.id.del);holder.how_time = (TextView) convertView.findViewById(R.id.how_time);holder.last_time = (TextView) convertView.findViewById(R.id.last_time);holder.avgValue = (TextView) convertView.findViewById(R.id.avgValue);holder.image = (ImageView)convertView.findViewById(R.id.image);holder.maxValue = (TextView)convertView.findViewById(R.id.maxValue);convertView.setTag(holder);} else {holder = (ViewHolder)convertView.getTag();}holder.image.setBackgroundResource((Integer)mData.get(position).get("image"));holder.del_btn.setOnClickListener(new View.OnClickListener() {public void onClick(View v) {mData.remove(position);mAdapter.notifyDataSetChanged(); }});holder.how_time.setText((String)(mData.get(position).get("how_time"))); holder.last_time.setText((String)(mData.get(position).get("last_time"))); holder.avgValue.setText((String)(mData.get(position).get("avgValue"))); holder.maxValue.setText((String)(mData.get(position).get("maxValue")));return convertView;}}这个相信都写烂了。
最后:代码下载地址:http://download.csdn.net/detail/aomandeshangxiao/4696742
晚安!
- 4楼cpzcy昨天 18:38
- 了解了
- Re: aomandeshangxiao昨天 19:50
- 回复cpzcyn其实 就是主要是动画效果。。。
- 3楼fwj380891124昨天 15:57
- 这标题起的...
- Re: aomandeshangxiao昨天 18:07
- 回复fwj380891124n哈哈,我是不是有给《环球时报》写稿的潜质。。。
- 2楼li_ruikai昨天 11:26
- 哥哥来看你了,
- Re: aomandeshangxiao昨天 13:13
- 回复li_ruikain你又不研究android。。。
- 1楼love_android_20113天前 19:06
- 向楼主借些学习这份编程的激情
- Re: aomandeshangxiao3天前 19:57
- 回复love_android_2011n程序员哪有不熬夜的啊。。。