import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;
import com.fortysevendeg.swipelistview.SwipeListView;
public class SwipeAdapter extends ArrayAdapter<String> {
private LayoutInflater mInflater ;
private List<String> objects ;
private SwipeListView mSwipeListView ;
public SwipeAdapter(Context context, int textViewResourceId,List<String> objects, SwipeListView mSwipeListView) {
super(context, textViewResourceId, objects);
this.objects = objects ;
this.mSwipeListView = mSwipeListView ;
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder = null ;
if(convertView == null){
convertView = mInflater.inflate(R.layout.list, parent, false);
holder = new ViewHolder();
holder.mFrontText = (TextView) convertView.findViewById(R.id.example_row_tv_title);
holder.mBackEdit = (Button) convertView.findViewById(R.id.edit);
holder.mBackDelete = (Button) convertView.findViewById(R.id.del);
convertView.setTag(holder);
}else{
holder = (ViewHolder) convertView.getTag();
}
holder.mBackDelete.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mSwipeListView.closeAnimate(position);
mSwipeListView.dismiss(position);
}
});
String item = getItem(position);
holder.mFrontText.setText(item);
return convertView;
}
class ViewHolder{
TextView mFrontText ;
Button mBackEdit,mBackDelete ;
}
}