daimajia / daimajia/AndroidSwipeLayout
Layout problem when changing the visibility of elements in ListView
- Dominant language
- Java
- Stars
- 12.3k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
I put the SwipeLayout in ListView (as root layout in convertview), different row has different button (different button counts / different operation), which is done by simply changing the visibility of the button. I find a similar issue [#129](https://github.com/daimajia/AndroidSwipeLayout/issues/129) in the **Closed Issues**. But it still happened.
I do the same thing in Demo App in latest version on master branch.
ListViewExample extends Activity:
```
mAdapter = new ListViewAdapter(this);
mListView.setAdapter(mAdapter);
mAdapter.setMode(Attributes.Mode.Single);
```
ListViewAdapter extends BaseSwipeAdapter:
```
@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.setShowMode(SwipeLayout.ShowMode.LayDown);
swipeLayout.addDrag(SwipeLayout.DragEdge.Right, swipeLayout.findViewWithTag("Bottom3"));
return v;
}
@Override
public void fillValues(int position, View convertView) {
TextView t = (TextView)convertView.findViewById(R.id.position);
t.setText((position + 1) + ".");
SwipeLayout swipeLayout = (SwipeLayout)convertView.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.findViewById(R.id.star).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(mContext, "Star", Toast.LENGTH_SHORT).show();
}
});
swipeLayout.findViewById(R.id.trash).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(mContext, "Trash Bin", Toast.LENGTH_SHORT).show();
}
});
swipeLayout.findViewById(R.id.magnifier).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(mContext, "Magnifier", Toast.LENGTH_SHORT).show();
}
});
swipeLayout.findViewById(R.id.trash).setVisibility(position%2 == 0 ? View.GONE : View.VISIBLE);
swipeLayout.findViewById(R.id.star).setVisibility(position%3 == 0 ? View.GONE : View.VISIBLE);
}
```
list_item.xml:
```
```
Then I swipe in ListView among different rows, randomly, weird layout happen:


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