tags:

views:

76

answers:

1

In my application I have a single EditText together with some TextViews, button and a spinner. My EditText receives focus since it is the only focusable view in this activity, I believe. My EditText shows with an orange border and cursor on the field.
Now I would like to remove the focus from this field (I don't want the cursor and border to show). Is there a way to do this?
I have been able to focus on the button by doing button.seFocusableInTouchMode() and button.requestFocus(). But this highlights the button and is obviously not what I want.

+2  A: 

check this question and the selected answer: http://stackoverflow.com/questions/1555109/stop-edittext-from-gaining-focus-at-activity-startup It's ugly but it works, and as far as I know there's no better solution.

Maragues
Thanks, I hadn't seen that one. My EditText was wrapped in a TableLayout, so doing this:<TableRow android:focusable="true" android:focusableInTouchMode="true"> <TextView android:id="@+id/phone_label" android:text="Telefon:" android:layout_height="wrap_content" /> <EditText android:id="@+id/phone" android:layout_height="wrap_content" /> </TableRow> solved the problem for me.
tobbenb3
great, it really is an ugly problem, and the solution isn't intuitive at all.
Maragues