How to set a few imeOptions programmatically
android, android-edittext, android-layout
Solution
Try like as below.
editText.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
Problem
I have `FrameLayout` container in which I want to add dynamically `EditText`. I need to set two `imeOptions`: `IME_ACTION_DONE` and `IME_FLAG_NO_EXTRACT_UI` in this same time but I have problem how to do it programmatically. My solution override my `imeOptions` (I now that is good behavior :) but I try everything) And my secound question: How to set focus after create EditText programmatically? This method `editText.requestFocus();` dosen't work for me. I want to open 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