Sanyasirao Mopada Sanyasirao Mopada - 1 year ago 146
Android Question

How to remove focus from edittext after setting sometext intially in programmatically?

I have an edit-text for date, and I am setting today's date as default date programmatically by, and I am opening a date-picker when focus changes, So here date-picker is opening when user opens the fragment, but I want to close it for the first time, How to achieve that?. Help me

date.setText(dateFormatter.format(new Date()));

Answer Source

I achieved it by removing focus when ondrawerClosed being called by navigation drawer

//In activity or fragment where we have navigation drawer
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {
        public void onDrawerClosed(View drawerView) {

        public void onDrawerOpened(View drawerView) {

//In fragment

public void removeFocus(){
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download