2013-06-05 3 views
4

이것은 Android 4.0 장치에서만 발생하는 문제입니다.HeaderView의 일부인 EditText가 입력에 초점을 잃음

현재 ListView와 ListActivity의 onCreate()를 추가하는 사용자 지정 헤더가 있습니다.

editText를 앱의 맞춤 검색 바에 사용합니다.

다음은 제 구현에 대해 설명하는 코드입니다. 이 코드는 안드로이드 2.3.5 장치에서 실행되면

 
private ListView lst_Reports = null; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    setContentView(R.layout.showreportlist); 

    lst_Reports = (ListView) findViewById(R.id.VuoShowReportsActivity_Lst_Reports); 

    /* 
    * Initialize UI 
    */ 

    LinearLayout headerView = (LinearLayout) View.inflate(this, R.layout.report_list_header, null); 
    EditText reportSearchBar = (EditText) headerView.findViewById(R.id.reportSearchBar); 
    lst_Reports.addHeaderView(headerView); 

    reportSearchBar.addTextChangedListener(new TextWatcher() { 

     public void afterTextChanged(Editable s) { 

     } 

     public void beforeTextChanged(CharSequence s, int start, int count, int after) { 

     } 

     public void onTextChanged(CharSequence s, int start, int before, int count) { 

      // do a search as and when the user inputs text 

      if (s != null && s.length() > 0) { 

       String query = s.toString(); 
       List queriedReports = getReportsBasedOnQueryString(query); 

      // populate the listView with the queriedReports 

      } 

     } 

    }); 

} 

protected List getReportsBasedOnQueryString(String query) { 
    // TODO Auto-generated method stub 
    return null; 
} 

, 그때는 EDITTEXT 정상적으로 입력 할 수 있습니다. 그러나 아이스크림 샌드위치가있는 Galaxy S3에 동일한 코드 조각을 배치하면 editText에서 한 번에 한 문자 씩 입력 할 수 있습니다. 키 입력이 끝날 때마다 포커스를 잃어 버리기 때문입니다.

나는 비슷한 문제에 대해 다음과 같은 제안 된 해결책을 이미 시도해 보았습니다. 그들 중 누구도이 문제를 해결하지 못했습니다.

  • 로이드 : windowSoftInputMode = "stateHidden"
  • 로이드 : windowSoftInputMode = "adjustPan"
  • 활동의 레이아웃 XML의 AndroidManifest를 내의 액티비티

    • :

      • 안드로이드 :

    descendantFocusability = "beforeDescendants는"나는 이것에 어떤 도움/의견을 보내 주셔서 감사하고 또한 다른 사람이 같은 문제를보고했습니다 있는지 알고 싶어입니다.

    감사 라자

  • 답변

    0
    public void onTextChanged(CharSequence s, int start, int before, int count) { 
    
         // do a search as and when the user inputs text 
    
         if (s != null && s.length() > 0) { 
    
          String query = s.toString(); 
          List queriedReports = getReportsBasedOnQueryString(query); 
    
         // populate the listView with the queriedReports 
    
         } 
         // add below line in your code 
         reportSearchBar.requestFocus(); 
    
    
        } 
    
    관련 문제