源码简介:仿qq未读消息,拖拽删除
源码效果:
源码片段:
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- getActionBar().hide();
- CoverManager.getInstance().init(this);
- ListView mList = (ListView) findViewById(R.id.list);
- mList.setAdapter(new DemoAdapter());
- CoverManager.getInstance().setMaxDragDistance(150);
- CoverManager.getInstance().setExplosionTime(150);
- }
- class DemoAdapter extends BaseAdapter {
- @Override
- public int getCount() {
- return 99;
- }
- @Override
- public Object getItem(int position) {
- return null;
- }
- @Override
- public long getItemId(int position) {
- return 0;
- }
- @Override
- public View getView(final int position, View convertView,
- ViewGroup parent) {
- convertView = LayoutInflater.from(MainActivity.this).inflate(
- R.layout.view_list_item, null);
- WaterDrop drop = (WaterDrop) convertView.findViewById(R.id.drop);
- drop.setText(String.valueOf(position));
- drop.setOnDragCompeteListener(new OnDragCompeteListener() {
- @Override
- public void onDrag() {
- // TODO Auto-generated method stub
- Toast.makeText(MainActivity.this, "remove:" + position,
- Toast.LENGTH_SHORT).show();
- }
- });
- return convertView;
- }
- }
- }