2012-01-04 2 views
1

tabhost에서 자동 초점과 관련된 문제가 있습니다. 더 나은 다음 사진 설명, softinput를 표시하고 내가 (그 글고 치기에) 해당 탭을 열 때 EDITTEXT에 초점을 맞출 필요가 :softInput을 표시하는 방법 : 비정상적인 동작으로 TabHost의 EditText

enter image description here

탭 하나에서 난 배치하는 것이 있습니다. 하지만 내가 열 때 editText는 포커스를 얻지 못합니다. 탭이 보여줄 때 editText 프로그램을 잘못 여는 것은 좋았지 만, 그 동작은 엉뚱한 것이며 두 번째 또는 세 번만 실행됩니다.

내가 원하는 것은 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> 

그리고 내가 활동 그룹으로 활동을 가지고,하지만 난 그것을 자동 초점 문제가 될 musn't 생각, 기본적으로이 내가하는 일입니다 해당 레이아웃 :

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); 
     ... 
    } 
    ... 
} 

감사합니다. 모든 도움을 주시면 감사하겠습니다. .도 \t \t ((InputMethodManager) getSystemService (Context.INPUT_METHOD_SERVICE)) showSoftInput (search_field으로,

EditText ET=(EditText) findViewById (R.id.search_field); 
ET.requestfocus(); 
ET.SetText("Your soft input"); 

답변

0

은 OnResume 재정에 다음을 추가 , 0);
+0

onResume 화재,하지만 부드러운 입력은 실행되지 않습니다 –

관련 문제