Ошибка, связанная с Android-PullToRefresh и его PullToRefreshExpandableListVIew

Я столкнулся с этой ошибкой при попытке использовать библиотеку Android-PullToRefresh из: https://github.com/chrisbanes/Android-PullToRefresh

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, поэтому изменение идентификатора на @android:id/list НЕ сработало для меня.

ПОМОЩЬ! Эта проблема сводит меня с ума!


person ctugino    schedule 18.01.2014    source источник


Ответы (1)


я думаю, вы можете установить адаптер на сам mPullToRefreshView, поскольку он уже является расширяемым списком. /samples/PullToRefreshExpandableListActivity.java" rel="nofollow">см. библиотеку, которую вы используете)

 mPullToRefreshView.setAdapter(lvadapter);

и удалить или прокомментировать это ..

ExpandableListView ActualView = mPullToRefreshView.getRefreshableView();

Гад удачи..:)

person Kalpesh Lakhani    schedule 18.01.2014
comment
Спасибо, НО это не работает. См. это (github .com/chrisbanes/Android-PullToRefresh/blob/master/library/). Не поддерживает BaseExpandableListAdapter... - person ctugino; 19.01.2014