I want to implement the SwipeListView like below image, I have download github code SwipeListView for that and make changes in it, But it fails what I want to implement
I want to implement that when user swipe listitem to left , two or three buttons should be display at right side
I make changes in above demo like below code
com.aug.swipe/MainActivity.java
protected View generateRightView(final int position) {
LinearLayout lnv_right = new LinearLayout(MainActivity.this);
LayoutParams lnv_params = new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
lnv_right.setOrientation(LinearLayout.HORIZONTAL);
TextView deleteView = new TextView(mContext);
LinearLayout.LayoutParams lp = new LayoutParams(200, 100);
deleteView.setLayoutParams(lp);
deleteView.setText("delete ");
deleteView.setGravity(Gravity.CENTER);
deleteView.setBackgroundColor(Color.parseColor("#12c2c2"));
deleteView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(mContext, "del " + mList.get(position),
Toast.LENGTH_SHORT).show();
mList.remove(position);
notifyDataSetChanged();
}
});
TextView editView = new TextView(mContext);
LinearLayout.LayoutParams edt_lp = new LayoutParams(200, 100);
editView.setLayoutParams(edt_lp);
editView.setText("delete ");
editView.setGravity(Gravity.CENTER);
editView.setBackgroundColor(Color.parseColor("#12c2c2"));
editView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(mContext, "del " + mList.get(position),
Toast.LENGTH_SHORT).show();
mList.remove(position);
notifyDataSetChanged();
}
});
lnv_right.addView(editView);
lnv_right.addView(deleteView);
lnv_right.setLayoutParams(lnv_params);
return lnv_right;
}
But this is not working , need any solution
Please use below code instead your code:
LayoutParams lnv_params = new LayoutParams(400, 100);