2013-06-06 2 views
0

나는 DragSortListView가 draghandle 이미지를 사용하여 항목을 재 배열 할 수있는 제 3 자 목록보기 자손을 기반으로하는있는 LinearLayout대화 상자가 표시되면 DialogFragment를 사용하지 않도록 설정하는 방법은 무엇입니까?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:padding="@dimen/dialog_main_margin" > 

<com.modelmakertools.simplemind.DragSortListView 
    android:id="@+id/drag_list_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

</LinearLayout> 

에 포함 된 DialogFragment에서 목록보기를 사용하고 있습니다.

이 코드가 (전체 화면) 활동에서 사용될 때만 작동하지만, android.support.v4.app.DialogFragment에서 사용될 때 항목을 드래그하면 대화 상자 + 목록보기 combi가 대화 상자 크기를 계속 업데이트합니다 . 이것은 매우 느린 드래그 원인과 내가 로그 캣 메시지를 많이 참조하십시오

06-06 15:37:07.833: I/Choreographer(17281): Skipped 166 frames! The application may be doing too much work on its main thread. 

이 문제의 원인을 찾으려면을, 차라리 match_parent/wrap_content보다 고정 400dp (로 목록보기의 폭과 높이를 변경). 크기를 완전히 고정하면 문제가 해결됩니다. 내 질문 : 한 번 레이아웃 한 번 크기를 조정하려면 대화 상자 조각을 피할 수있는 방법이 있습니까?

답변

1

아래 코드를 사용하여 대화 상자 크기를 업데이트하는 listview를 중지하는 방법을 찾았습니다. 그러나 이것은 문제의 일부분 만 해결합니다. 목록이 "고정"될 때까지로드가 여전히 매우 느립니다. 하지만이 질문의 범위를 넘어 또 다른 원인이있다/

@Override 
public void onResume() { 
    super.onResume(); 
    // Fixate the listview height once the listview has been measured rather than keeping it at "wrap_content" 
    // This drastically improves rearrange performance. 
    if (_listView != null) { 
     _listView.postDelayed(new Runnable() { 
      @Override 
      public void run() { 
       fixateListViewHeight(); 
      } 
     }, 500); 
    } 
} 

private void fixateListViewHeight() { 
    if (_listView != null) { 
     int h = _listView.getMeasuredHeight(); 
     if (h != 0) { 
      LayoutParams params = (LayoutParams) _listView.getLayoutParams(); 
      if (params != null) 
       params.height = h; 
     } 
    } 
} 
0

대화 조각을 사용하는 활동의 AndroidManifest.xmladjustNothingwindowSoftInputMode 속성을 설정하십시오 응답합니다.

<activity 
    ... 
    android:windowSoftInputMode="adjustNothing"> 
... 
+0

대화 상자의 자동 크기 조정에 초기 조정이 필요하므로 작동하지 않습니다. 또한 다른 대화 상자의 경우 자동 크기 조정 기능을 사용할 수 없습니다. –

+0

이 조정은 소프트 키보드에 대한 것으로, 표시 할 때 현재보기와 겹칠 것입니다. –

+0

아, 활동 내용보기를 줄이기 위해 소프트 키보드가 필요하므로 사용할 수 없습니다. –

관련 문제