-4

In TabLayout there are 4 tabs. At 2nd tab I have EditText(for search).When entered some text in EditText and when swipe to another tab again and I come back to watch EditText, whatever I entered text which is not cleared. But I want to clear EditText when swiped to other tab.

Please watch this image

sharp
  • 1,199
  • 14
  • 38
Lokesh
  • 316
  • 3
  • 14

2 Answers2

0

try this in your edittext fragment..

@Override
    public void setMenuVisibility(final boolean visible) {
        super.setMenuVisibility(visible);
        if (visible) {


        }
        else
        {       
        edittext.setText("");
        }
    }
faisal iqbal
  • 694
  • 1
  • 6
  • 19
0

in your onResume() of the fragment clear the edittext like this.

@Override
    public void onResume() {
        super.onResume();
        yourEditText.getText().clear(); //or yourEditText.setText("");
    }
hushed_voice
  • 2,580
  • 1
  • 26
  • 51