2014-01-18 21 views
0

我遇到這個錯誤錯誤: https://github.com/chrisbanes/Android-PullToRefresh當我嘗試從使用Android-PullToRefresh庫有關Android的PullToRefresh及其PullToRefreshExpandableListVIew

1255-1255/cn.thu.uems E/AndroidRuntime﹕ FATAL EXCEPTION: main 
java.lang.RuntimeException: Unable to start activity ComponentInfo{cn.thu.uems/cn.thu.uems.MainUI}: java.lang.RuntimeException: Your content must have a ExpandableListView whose id attribute is 'android.R.id.list' 

這是我的相關XML文件:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#eee" 
    android:orientation="vertical" > 
    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="45dp" 
     android:id="@+id/title" 
     android:background="@drawable/title_bar" 
     android:gravity="center_vertical" > 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="State" 
      android:layout_centerInParent="true" 
      android:textSize="20sp" 
      android:textColor="#ffffff" /> 
     <Button 
      android:layout_width="90dp" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:layout_centerVertical="true" 
      android:layout_marginRight="5dp" 
      android:text="History" 
      android:textColor="#fff" 
      android:textSize="15dp" 
      android:background="@drawable/title_btn_right" 
     /> 
    </RelativeLayout> 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <com.handmark.pulltorefresh.library.PullToRefreshExpandableListView 
      xmlns:ptr="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/pull_list" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      /> 
    </LinearLayout> 
</LinearLayout> 

這是我的代碼相關:

mPullToRefreshView = (PullToRefreshExpandableListView) findViewById(R.id.pull_list); 
    mPullToRefreshView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<ExpandableListView>() { 
     @Override 
     public void onRefresh(PullToRefreshBase<ExpandableListView> expandableListViewPullToRefreshBase) { 
      new GetDataTask().execute(); 
     } 
    }); 
    lvadapter = new LoadsViewAdapter(this, groupEntity, childEntity); 
    ExpandableListView ActualView = mPullToRefreshView.getRefreshableView(); 
    ActualView.setAdapter(lvadapter); 

PS:我沒有擴展ListActivity或ExpandableListActivity,因此將ID更改爲@android:id/list對我無效。

幫助!這個問題讓我瘋狂!

回答

0

我想你可以設置適配器mPullToRefreshView本身,因爲它已經是可擴展的ListView ..(see at library you are using

mPullToRefreshView.setAdapter(lvadapter); 

,並刪除或評論這個..

ExpandableListView ActualView = mPullToRefreshView.getRefreshableView(); 

GUD運氣..: )

+0

謝謝,但它不工作。看到這個(https://github.com/chrisbanes/Android-PullToRefresh/blob/master/library/src/com/handmark/pulltorefresh/library/PullToRefreshAdapterViewBase.java)。不支持BaseExpandableListAdapter ... – ctugino

相關問題