问题描述:

I try to use Pull-to-Refresh by Chrisbanes and android-uitableview by thiagolocatelli.

Because all of them extends LinearLayout. So i try to change:

UITableView extends PullToRefreshListView

The problem is:

  • I cannot pull my UITableView

  • Because layout of UITableView and PullToRefreshListView are LinearLayout. How can i change my layout like this:

Thanks


UPDATE

Base on Chrisbanes's answer , i have my layout

<com.mypacket.widget.PullToRefreshScrollView

android:id="@+id/observable_scroll_view"

android:layout_width="fill_parent"

android:layout_height="wrap_content" >

<com.mypacket.widget.UITableView

android:id="@+id/tableView"

style="@style/UITableView" />

</com.mypacket.widget.PullToRefreshScrollView>

And my code:

mObservableScrollView = (PullToRefreshScrollView) findViewById(R.id.observable_scroll_view);

mTableView = (UITableView) findViewById(R.id.tableView);

// Set a listener to be invoked when the list should be refreshed.

mObservableScrollView.setOnRefreshListener(new OnRefreshListener<ScrollView>() {

@Override

public void onRefresh(PullToRefreshBase<ScrollView> refreshView) {

new GetDataTask().execute();

}

});

mObservableScrollView.setMode(Mode.PULL_UP_TO_REFRESH);

private class GetDataTask extends AsyncTask<Void, Void, String> {

@Override

protected String doInBackground(Void... params) {

// Simulates a background job.

try {

Thread.sleep(1000);

Log.i(TAG, "REFRESHHHHHHHHHHHHHHHHHHHHHHHHHHH");

} catch (InterruptedException e) {

}

return "";

}

@Override

protected void onPostExecute(String result) {

// Call onRefreshComplete when the list has been refreshed.

mObservableScrollView.onRefreshComplete();

super.onPostExecute(result);

}

}

But nothing changes, i cannot scroll, cannot pull

网友答案:

I recently added PullToRefreshScrollView which should help you here. Just replace your ScrollView with PullToRefreshScrollView.

PullToRefreshScrollView is in the dev branch for now, but will be in master for next release.

相关阅读:
Top