I created my own keyboard and I want to show it when the user clicks/touches the EditText
. I googled the issue and tried several ways to make it; however, none of them worked for me. Also, I did not find any mistakes if I made some in the code. So here is the code lines:
minText = (EditText) findViewById( R.id.minLetField );
minText.setOnTouchListener( new OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent event)
{
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "CLICKED-MIN", Toast.LENGTH_SHORT).show();
getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
return false;
}
});
When I run the app, the toast message appears but the keyboard does not hide. Also I tried it in clickListener
like that:
minText.setOnClickListener( new View.OnClickListener()
{
@Override
public void onClick(View v)
{
isMinTextField = true;
Toast.makeText(getApplicationContext(), "CLICKED-MIN", Toast.LENGTH_SHORT).show();
getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
//enableKeyboard();
}
});
But it gave the same result.
Using
setInputType(0);
solves the problem.