<!-- Dummy item to prevent AutoCompleteTextView from receiving focus --><LinearLayoutandroid:focusable="true"android:focusableInTouchMode="true"android:layout_width="0px"android:layout_height="0px"/>
<!-- :nextFocusUp and :nextFocusLeft have been set to the id of this componentto prevent the dummy from receiving focus again --><AutoCompleteTextView android:id="@+id/autotext"android:layout_width="fill_parent"android:layout_height="wrap_content"android:nextFocusUp="@id/autotext"android:nextFocusLeft="@id/autotext"/>
addButton.setOnClickListener(new OnClickListener() {public void onClick(View v) {View focused = internalWrapper.getFocusedChild();focused.setVisibility(GONE);v.requestFocus();addPanel();focused.setVisibility(VISIBLE);}});
Basically, hide the edit text and then show it again. This works for me as the EditText is **not** in view so it doesn't matter whether it is showing.
You could try hiding and showing it in succession to see if that helps it lose focus.
@Overrideprotected void onResume() {super.onResume();
//do not give the editbox focus automatically when activity startsmAutoCompleteTextView.clearFocus();mLinearLayout.requestFocus();}
<EditTextandroid:id="@+id/emailField"android:layout_width="fill_parent"android:layout_height="wrap_content"android:inputType="textEmailAddress">
//<requestFocus /> /* <-- without this line */</EditText>
<EditTextandroid:id="@+id/input"android:layout_width="fill_parent"android:layout_height="wrap_content">
<requestFocus /> <!-- remove this line --></EditText>
<!-- fake first focusable view, to allow stealing the focus to itself when clearing the focus from others -->
<Viewandroid:layout_width="0px"android:layout_height="0px"android:focusable="true"android:focusableInTouchMode="true" />