Back to project page AndroidSwipeLayout.
The source code is released under:
MIT License
If you think the Android project AndroidSwipeLayout listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.daimajia.swipedemo.adapter; /*w ww . j av a 2 s. c o m*/ import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import com.daimajia.androidanimations.library.Techniques; import com.daimajia.androidanimations.library.YoYo; import com.daimajia.swipe.SimpleSwipeListener; import com.daimajia.swipe.SwipeLayout; import com.daimajia.swipe.adapters.BaseSwipeAdapter; import com.daimajia.swipedemo.R; public class ListViewAdapter extends BaseSwipeAdapter { private Context mContext; public ListViewAdapter(Context mContext) { this.mContext = mContext; } @Override public int getSwipeLayoutResourceId(int position) { return R.id.swipe; } @Override public View generateView(int position, ViewGroup parent) { View v = LayoutInflater.from(mContext).inflate(R.layout.listview_item, null); SwipeLayout swipeLayout = (SwipeLayout)v.findViewById(getSwipeLayoutResourceId(position)); swipeLayout.addSwipeListener(new SimpleSwipeListener() { @Override public void onOpen(SwipeLayout layout) { YoYo.with(Techniques.Tada).duration(500).delay(100).playOn(layout.findViewById(R.id.trash)); } }); swipeLayout.setOnDoubleClickListener(new SwipeLayout.DoubleClickListener() { @Override public void onDoubleClick(SwipeLayout layout, boolean surface) { Toast.makeText(mContext, "DoubleClick", Toast.LENGTH_SHORT).show(); } }); return v; } @Override public void fillValues(int position, View convertView) { TextView t = (TextView)convertView.findViewById(R.id.position); t.setText((position + 1) + "."); } @Override public int getCount() { return 50; } @Override public Object getItem(int position) { return null; } @Override public long getItemId(int position) { return position; } }