XMl布局文件
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:focusable="true" android:focusableInTouchMode="true" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <com.handmark.pulltorefresh.library.PullToRefreshScrollView xmlns:ptr="http://schemas.android.com/apk/res-auto" android:id="@+id/pull_refresh_scrollview" android:layout_width="fill_parent" android:layout_height="fill_parent" ptr:ptrAnimationStyle="flip" ptr:ptrMode="both" > <ScrollView android:id="@+id/my_scroll_view" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> <Spinner android:background="#ffffff" android:id="@+id/sp_company" android:layout_width="match_parent" android:layout_height="wrap_content"/> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <Spinner android:layout_weight="1" android:background="#ffffff" android:layout_marginLeft="10dp" android:id="@+id/sp_company_supervision" android:layout_width="0dp" android:layout_height="match_parent"/> <Spinner android:layout_marginRight="10dp" android:layout_weight="1" android:background="#ffffff" android:layout_marginLeft="10dp" android:id="@+id/sp_company_construction" android:layout_width="0dp" android:layout_height="match_parent"/> </LinearLayout> <Spinner android:background="#ffffff" android:layout_marginLeft="10dp" android:id="@+id/sp_company_team" android:layout_width="match_parent" android:layout_height="wrap_content"/> <LinearLayout android:layout_marginTop="10dp" android:gravity="center" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:layout_marginLeft="10dp" android:layout_weight="8" android:singleLine="true" android:hint="按姓名搜索" android:background="#ffffff" android:id="@+id/et_input_farmer_name" android:layout_width="0dp" android:layout_height="40dp" /> <Button android:textColor="#ffffff" android:text="查询" android:layout_marginRight="10dp" android:layout_weight="2" android:background="#04a3f2" android:id="@+id/bt_input_farmer_name" android:layout_width="0dp" android:layout_height="40dp" /> </LinearLayout> <Spinner android:background="#ffffff" android:layout_marginTop="10dp" android:layout_gravity="center_horizontal" android:id="@+id/sp_company_wage_years" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <com.example.bing.workerwages.WholeLiistView android:id="@+id/gv_farmer_wages" android:layout_width="match_parent" android:layout_height="wrap_content" /> <com.example.bing.workerwages.WholeListView android:layout_marginTop="20dp" android:id="@+id/lv_wages_list" android:layout_width="match_parent" android:layout_height="wrap_content"> </com.example.bing.workerwages.WholeListView> </LinearLayout> </ScrollView> </com.handmark.pulltorefresh.library.PullToRefreshScrollView> </LinearLayout>
代码片段
pull_refresh_scrollview.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ScrollView>() { @Override public void onPullDownToRefresh(PullToRefreshBase<ScrollView> refreshView) { } @Override public void onPullUpToRefresh(PullToRefreshBase<ScrollView> refreshView) { pull_refresh_scrollview.post(new Runnable() { @Override public void run() { fwl_page_index=""+fwl_page_index_int; farmer_wages_list_result=""; init_farmer_wages_list(); if (farmer_wages_list_result.contains("company_name")){ fwl_page_index_int++;} pull_refresh_scrollview.onRefreshComplete(); } }); } })