@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); // 这里要主要requestWindowFeature和setContentView先后顺序哦 setContentView(R.layout.listactivity_mylistview4); mData = getData(); adapter = new MyAdapter(this); setListAdapter(adapter); btnback = (ImageButton) findViewById(R.id.btnback); btnright = (ImageButton) findViewById(R.id.btnright); camera = (TextView) findViewById(R.id.camera); camera.setClickable(true); camera.setFocusable(true); camera.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub letCamera(); } }); btnback.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub finish(); // 返回动画 overridePendingTransition(R.anim.back_slide_in_left, R.anim.back_slide_in_right); } }); btnright.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (mData.size() != 0) { Intent intent = new Intent(MyListView4.this, TagActivity.class); startActivity(intent); // 前进动画 overridePendingTransition( R.anim.forward_slide_in_left, R.anim.forward_slide_out_right); } else { Toast.makeText(MyListView4.this, "请添加至少一张图片哦~", Toast.LENGTH_SHORT).show(); } } }); // list滑动删除 SwipeDismissAdapter swipeDismissAdapter = new SwipeDismissAdapter(adapter, new MyOnDismissCallback()); swipeDismissAdapter.setListView(getListView()); getListView().setAdapter(swipeDismissAdapter); // listview从左淡入动画,依赖library包 SwingLeftInAnimationAdapter swingLeftInAnimationAdapter = new SwingLeftInAnimationAdapter(adapter); swingLeftInAnimationAdapter.setListView(getListView()); getListView().setAdapter(swingLeftInAnimationAdapter); }
private void setSwipeDismissAdapter() { SwipeDismissAdapter adapter = new SwipeDismissAdapter(mAdapter, this); adapter.setAbsListView(getListView()); getListView().setAdapter(adapter); }