[android] Clear text in EditText when entered

In XML you can write like:

    <EditText
        android:id="@+id/txtsearch"
        android:layout_width="250dp"
        android:layout_height="match_parent"
        android:layout_gravity="right"
        android:layout_weight="1"
        android:background="@drawable/roundlayoutbutton1"
        android:ems="10"
        android:gravity="center"
        android:inputType="text"
        android:textAllCaps="true"
        android:text="search_xxxx"

        android:textColor="@color/colorPrimaryDark"
        android:visibility="visible" />

and in java class you may have below one :

    EditText searchHost;

OnCreate() you write:

    searchHost=findViewById(R.id.txtsearch);

    searchHost.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if(searchHost.getText().toString().equalsIgnoreCase("search_xxxx")){
                searchHost.setText("");
                Toast.makeText(getApplicationContext(),"Enter you text xxx...", Toast.LENGTH_LONG).show();
            }
        }
    });

It works fine for me.