-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,191
  • 14
  • 39
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
  • 724
  • 1
  • 8
  • 20
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
  • 3,161
  • 3
  • 34
  • 66