i want to hide the soft keyboard when i click out side of editbox in a screen. how can i do this?
This can be done using following code :
1) Take a reference of your parent layout into java code by using findViewById().
2) then apply setOnTouchListener() to it.
3) Add following code in onTouchMethod().
lin = (LinearLayout) findViewById(R.id.lin);
lin.setOnTouchListener(new OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent event)
{
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0);
return false;
}
});