I have a FrameLayout container in which I want to add a dynamically EditText . I need to set two imeOptions : IME_ACTION_DONE and IME_FLAG_NO_EXTRACT_UI for the same time, but I have a problem how to do this programmatically. My solution overrides my imeOptions (I now have this nice behavior :), but I try everything)
And my question is: how to adjust focus after creating EditText programmatically? This method is editText.requestFocus(); not working for me. I want to open the keyboard after postCardContainer.addView(editText);
postCardContainer.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.topMargin = (int) event.getY()-50; params.leftMargin = (int) event.getX()-50; EditText editText = new EditText(NewPostcardActivity.this); editText.setSingleLine(); editText.setBackgroundResource(R.color.transparent); editText.requestFocus(); editText.setLayoutParams(params); editText.setCursorVisible(true); editText.setImeOptions(EditorInfo.IME_ACTION_DONE); editText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); postCardContainer.addView(editText); return false; } });
thanks
source share