0

저는 관리자 클래스를 사용하여 클래스의 정보 (내 모델의 Guest)를 가져 오는 RoboListFragment 클래스를 확장했습니다. 내가 직면하고있는 문제는이 관리자가 데이터를 검색하지 못하는 경우이며, 표시된 진행률 표시 줄을 닫고 싶습니다. 여기 내 조각의 가장 중요한 부분입니다ListView의 내용을로드하지 못했을 때 Android 진행률 표시 줄을 닫는 방법?

public class GuestFragment extends RoboListFragment { 

    // Lines omitted 

    private void loadGuest() { 
     Log.d(GuestFragment.class.getSimpleName(), "Loading guest..."); 
     this.guestManager.getGuest(new Callback<Guest>() { 
      @Override 
      public void onSuccess(Guest guest) { 
       Log.d(GuestFragment.class.getSimpleName(), "Guest loaded OK"); 
       GuestFragment.this.createAdapter(guest); 
      } 

      @Override 
      public void onFailure(UmError ex) { 
       // Here I want to dismiss the ProgressBar 
       Log.d(GuestFragment.class.getSimpleName(), "Guest failed"); 
       GuestFragment.this.getListView().setEmptyView(new View(getActivity()));  // This line wouldn't work 
       Toast.makeText(GuestFragment.this.getActivity(), "Error here!", Toast.LENGTH_LONG); 
      } 
     }); 
    } 

    private void createAdapter(Guest guest) { 
     // Lines omitted 
     if (guestExists && activityWasCreated) { 
      ArrayAdapter adapter = new ProfilesAdapter(this.getActivity(), guest.getDeliveryProfiles()); 
      this.setListAdapter(adapter); 
     } 

    } 
} 

수정 # 1 : 내 onFailure() 방법

GuestFragment.this.getListView().setAdapter(null) 

이 줄을 추가 시도했지만 작동하지 않았다. 편집 # 2 : 나는 또한 내 onFailure() 방법이 추가 시도

GuestFragment.this.getListView().setEmptyView(null); 

중 하나가 작동하지 않았다.

는 XML

은 매우 간단합니다 : 당신이 볼 수 있듯이

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:padding="@dimen/pLarge" 
android:orientation="vertical" 
tools:context=".fragment.GuestFragment"> 

    <ListView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@id/android:list" 
     android:divider="@android:color/transparent" 
     android:dividerHeight="@dimen/fSmaller"/> 
</LinearLayout> 

, 나는 전혀 ProgressBar를 정의하고 있지 않다. 이 ProgressBar는 어댑터가 설정 될 때까지 안드로이드에서 표시됩니다 (자세한 내용은 없음). 그러나 빈 내용을 설정하는 방법을 모르겠다.

어떻게 달성 할 수 있습니까? 이 때문에 콜백이 성공적으로 반환 될 때 ProgressBar가 숨겨집니다. 감사합니다.

+0

어디서 진행 표시 줄을 설정합니까? – Mou

+0

onFailure 빈 어댑터를 작성하십시오. – Rohit5k2

+0

@Mou 진행률 표시 줄을 설정하지 않습니다. – jmm

답변

0
내가 ( 올바른 방법)과 같이 목록 어댑터에 null을 설정하는 대신 바보 같은 실수 :(

을 만들고 있었다

:

GuestFragment.this.setListAdapter(null) 

나는 ListView 및 세트를 얻으려고 노력했다 null 어댑터는 다음과 같습니다.

GuestFragment.this.getListView().setAdapter(null) 

감사합니다. 어쨌든!