Commit 67f6bef9 authored by fallenstardust's avatar fallenstardust

优化输入框清空逻辑

parent 784bea2d
...@@ -49,8 +49,8 @@ public class DeckSquareFragment extends Fragment { ...@@ -49,8 +49,8 @@ public class DeckSquareFragment extends Fragment {
//查询卡组名称 //查询卡组名称
binding.etDeckSquareInputDeckName.setOnEditorActionListener((v, actionId, event) -> { binding.etDeckSquareInputDeckName.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_SEARCH) { if (actionId == EditorInfo.IME_ACTION_SEARCH) {
Editable contributerName = binding.etInputContributorName.getText(); Editable contributorName = binding.etInputContributorName.getText();
if (contributerName != null) contributerName.clear(); if (contributorName != null) contributorName.clear();
keyWord = v.getText().toString(); keyWord = v.getText().toString();
binding.etGoToPage.setText("1"); binding.etGoToPage.setText("1");
binding.etGoToPage.setEnabled(false); binding.etGoToPage.setEnabled(false);
...@@ -67,7 +67,10 @@ public class DeckSquareFragment extends Fragment { ...@@ -67,7 +67,10 @@ public class DeckSquareFragment extends Fragment {
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
binding.btnClearDeckName.setVisibility(View.VISIBLE); if (s.toString().isEmpty())
binding.btnClearDeckName.setVisibility(View.GONE);
else
binding.btnClearDeckName.setVisibility(View.VISIBLE);
} }
@Override @Override
...@@ -122,7 +125,12 @@ public class DeckSquareFragment extends Fragment { ...@@ -122,7 +125,12 @@ public class DeckSquareFragment extends Fragment {
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
binding.btnClearContributorName.setVisibility(View.VISIBLE); if (s.toString().isEmpty()) {
binding.btnClearContributorName.setVisibility(View.GONE);
} else {
binding.btnClearContributorName.setVisibility(View.VISIBLE);
}
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment