EDITO1:
public class Prueba extends AppCompatActivity implements SimpleGestureListener {
TextView TextView1;
GestosActivity detector;
EditText editTextNombre;
View view;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.prueba);
// Oculta teclado al iniciar la Activity
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
editTextNombre = (EditText) findViewById(R.id.editTextNombre);
TextView1 = (TextView) findViewById(R.id.TextView1);
// gestos
detector = new GestosActivity(this, this);
editTextNombre.setOnFocusChangeListener(new OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if(!hasFocus) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
});
}
// gestos
@Override
public boolean dispatchTouchEvent(MotionEvent me) {
this.detector.onTouchEvent(me);
return super.dispatchTouchEvent(me);
}
@Override
public void onSwipe(int direction) {
switch (direction) {
case GestosActivity.SWIPE_DOWN:
Toast.makeText(this, "Sin función de momento", Toast.LENGTH_LONG).show();
break;
case GestosActivity.SWIPE_UP:
Toast.makeText(this, "Sin función de momento", Toast.LENGTH_LONG).show();
}
}
}