У меня проблемы с автофокусом в табхосте. Мне нужно отобразить softinput и фокус в editText, когда я открываю эту вкладку (с этим edittext), лучше объяснено следующим рисунком:
В одной вкладке у меня есть этот макет. Но когда я открываю его, editText не получает фокус. Я сделал это плохо, открывая программу editText, когда отображается вкладка, но ее поведение ошибочно и она запускается только второй или третий раз.
Я хочу сделать это автоматически, как это часто бывает с Android на editText. Я поставил код сейчас:
tab_header.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/AbsoluteLayout01"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/search_bar"
android:layout_alignParentTop="true"
android:background="#FF000000"
android:layout_centerVertical="true"
android:orientation="horizontal"
android:paddingTop="6dip"
android:paddingBottom="6dip"
android:weightSum="4.0">
<EditText android:id="@+id/search_field"
android:layout_height="45dip"
android:maxHeight="45dip"
android:layout_width="0dip"
android:layout_weight="3.1"
android:maxLines="1"
android:lines="1"
android:focusable="true"
android:focusableInTouchMode="true"
android:imeOptions="flagNoExtractUi"
android:textSize="18dip"
android:hint="@string/search_hint_text"
android:textColorHint="@color/edit_text_hint_search"
android:background="@drawable/et_search_field"
android:textColor="@color/edit_text"
android:layout_marginLeft="2dip"
android:layout_marginRight="0dip"
android:textColorHighlight="@color/edit_text_highlight" />
<ImageButton android:text="Search" android:src="@drawable/ic_search_normal" android:id="@+id/search_button"
android:layout_width="0dip"
android:layout_height="45dip"
android:layout_weight="0.9"
android:scaleType="fitCenter"
android:layout_alignTop="@+id/search_field"
android:layout_alignBottom="@+id/search_field"
android:background="@drawable/button_generic"
android:layout_marginLeft="6dip"
android:layout_marginRight="2dip"
android:padding="10dip"/>
</LinearLayout>
</RelativeLayout>
Затем у меня есть активность в группе действий, но я думаю, что это не будет проблемой для автофокуса, в основном это то, что я делаю с этим макетом:
public class SearchListActivity extends ListActivity implements OnScrollListener
{
...
@Override
public void onCreate(Bundle savedInstanceState)
{
...
View v = View.inflate(this, R.layout.tab_header, null);
getListView().addHeaderView(v);
...
}
...
}
Спасибо за чтение, вся помощь будет с благодарностью прочитана.