daimajia / daimajia/AndroidSwipeLayout
swipelayout issue (listview remove and add)
- Dominant language
- Java
- Stars
- 12.3k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
When I remove the last swipelayout from the listview and then notifydatachanged, then add another new swipelayout in the listview, i get the swipe layout status is close, but it shows open, why?
here is listview item xml:
```
```
here is my adapter:
class RecipeAdapter extends BaseSwipeAdapter {
```
Context context;
List data;
public RecipeAdapter(Context context, List data) {
this.context = context;
this.data = data;
}
@Override
public int getSwipeLayoutResourceId(int i) {
return R.id.swipe;
}
@Override
public View generateView(int position, ViewGroup viewGroup) {
View v = LayoutInflater.from(context).inflate(R.layout.plan_select_recipe_item, null);
final 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));
}
});
return v;
}
@Override
public void fillValues(final int i, View view) {
Log.v(i + "", view.toString());
TextView text1 = (TextView) view.findViewById(R.id.textview1);
TextView text2 = (TextView) view.findViewById(R.id.textview2);
TextView text3 = (TextView) view.findViewById(R.id.textview3);
Object obj = data.get(i);
if(obj instanceof Recipe) {
text1.setText(((Recipe)obj).getTitle());
text2.setText(((Recipe)obj).getTotal_amount() + "g");
text3.setText(Math.round(((Recipe)obj).getCalories() * ((Recipe)obj).getTotal_amount() / 100) + "kcal");
}
view.findViewById(R.id.trash).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
data.remove(i);
notifyDataSetChanged();
Toast.makeText(context, "click delete", Toast.LENGTH_SHORT).show();
}
});
}
@Override
public int getCount() {
return data.size();
}
@Override
public Object getItem(int position) {
return data.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
}
```

Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.