Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

change focus of edittext android when click outside

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        View v = getCurrentFocus();
        if ( v instanceof EditText) {
            Rect outRect = new Rect();
            v.getGlobalVisibleRect(outRect);
            if (!outRect.contains((int)event.getRawX(), (int)event.getRawY())) {
                v.clearFocus();
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
            }
        }
    }
    return super.dispatchTouchEvent( event );
}
Comment

PREVIOUS NEXT
Code Example
Java :: how to move get selected from jfxtreetableview javafx 
Java :: Arraylist imp for recursion 
Java :: do switch statement always run default java 
Java :: interviewbit_java 
Java :: how to read space separated characters in java 
Java :: how to convert string to int android studio kotlin 
Java :: IMEI DEVISE ANDROID JAVA 
Java :: java Sum of all the factors of a number 
Java :: how to make a typewriter effect in jaca 
Java :: subtract two variables in java 
Java :: bf5 cheat detector 
Java :: how to clear the consol after input java 
Java :: Volkswagen fox 
Java :: for each loop summation 
Java :: Java Insert Elements to LinkedHashSet 
Java :: print current user roles in java 
Java :: 2 multiples 
Java :: print map in java log 
Java :: material design implement full screen dialog android java 
Java :: java boolean zen 
Java :: java thread syncronized locker 
Java :: java radom float 
Java :: try catch not working java 
Java :: java schleifendurchläufe zählen 
Java :: java list to collections 
Java :: list all android sensors in java 
Java :: how to shorten if else if and else in java 
Java :: how to fetch email and get there body content in spring boot 
Java :: Mirror Inverse Program in java 
Java :: Java program to find largest of three numbers using nested if 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =