daimajia / AndroidSwipeLayout

The Most Powerful Swipe Layout!
MIT License
12.38k stars 2.67k forks source link

Can not manage to dynamically populate the "actions" #494

Open Chuque opened 6 years ago

Chuque commented 6 years ago

the items that are revealed when we swype, let's call them "actions". I can add those actions on xml, but have not found a way to programmatically populate them for each item. how can achieve this? If I should not open an issue for this, let me know.

Chuque commented 6 years ago

any help here please?

Troyaz12 commented 6 years ago

Hello, I'm just an end user, but I have found you can add items to a when using a recyclerview by adding the following code to onBindViewHolder inside your adapter:

    LinearLayout myLayout = viewHolder.swipeLayout.findViewById(R.id.bottom_wraper);
    Button myButton = new Button(mContext);
    myButton.setText("New Button");
    myButton.setTextSize(12);
    myButton.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    myLayout.addView(myButton);

Hope that helps.