diff --git a/app/src/main/java/moe/codeest/enviewsdemo/ScrollActivity.java b/app/src/main/java/moe/codeest/enviewsdemo/ScrollActivity.java index 4d25975..fe55d52 100644 --- a/app/src/main/java/moe/codeest/enviewsdemo/ScrollActivity.java +++ b/app/src/main/java/moe/codeest/enviewsdemo/ScrollActivity.java @@ -14,26 +14,22 @@ public class ScrollActivity extends Activity{ ENScrollView scrollView; - Button btnSelect; - Button btnUnSelect; + Button btnSwitch; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_scroll); scrollView = (ENScrollView) findViewById(R.id.view_scroll); - btnSelect = (Button) findViewById(R.id.btn_select); - btnUnSelect = (Button) findViewById(R.id.btn_unselect); - btnSelect.setOnClickListener(new View.OnClickListener() { + btnSwitch = (Button) findViewById(R.id.btn_switch); + btnSwitch.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - scrollView.select(); - } - }); - btnUnSelect.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - scrollView.unSelect(); + if (scrollView.isSelected()) { + scrollView.unSelect(); + } else { + scrollView.select(); + } } }); } diff --git a/app/src/main/res/layout/activity_play.xml b/app/src/main/res/layout/activity_play.xml index 4a7967c..9142159 100644 --- a/app/src/main/res/layout/activity_play.xml +++ b/app/src/main/res/layout/activity_play.xml @@ -18,17 +18,17 @@ app:play_bg_line_width="12"/>