Question

I have 1 edit text in my activity in that when i press a button soft keyboard opens and on hardware backbutton the softkeyboard is closed and cursor should be visible gone..i have implemented as below..Please help me for it..

public void onBackPressed()
    {


            brand.setCursorVisible(false);
            brand.clearFocus();

        finish();

    }

}
Was it helpful?

Solution

Try this way

public void onBackPressed()
    {

            if(brand.isCursorVisible()){
                brand.setCursorVisible(false);
                brand.clearFocus();
            }else{
                super.onBackPressed();
            }

    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top