daimajia / daimajia/AndroidSwipeLayout

Main-layout change while in a sided-layout.

Open
#426 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
12.3k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Hello,
I have an issue when changing the text of a TextView in the main layout while my right-sided layout is visible. When I change the text, the right-sided layout is immediately hidden instead of remaining visible.

I've made this simple application to illustrate my problem. The number in the TextView is incremented every 3 seconds. So if you drag the right-sided layout, at the next incrementation, the layout will "refresh/reset" himself and i don't want that.

PS: When I set layout_width="match_parent" of the TextView, the problem doesn't happen.

_Sources:_
MainActivity.java
```
public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.item_layout);

TextView countView = (TextView) findViewById(R.id.count);
new Value(countView);

SwipeLayout swipeLayout = (SwipeLayout) findViewById(R.id.swipe);
LinearLayout rightLayout = (LinearLayout) findViewById(R.id.right);
swipeLayout.setShowMode(SwipeLayout.ShowMode.LayDown);
swipeLayout.addDrag(SwipeLayout.DragEdge.Right, rightLayout);
}
}
```
Value.java
```
public class Value {
private int value = 0;
private final TextView view;

private final Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
value++;
view.setText(value+"");
}
};

public Value(TextView v) {
view = v;
incrementThread();
}

public void incrementThread() {
new Thread(new Runnable() {
@Override
public void run() {
while (true)
try {
handler.sendEmptyMessage(0);
Thread.sleep(2000);
} catch (InterruptedException ignored) {
}
}
}).start();
}
}
```
item_layout.xml
```



```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.