增加水平+垂直滚动+首行首列固定+翻页Listview例子
This commit is contained in:
parent
62e74a3670
commit
789a618026
|
@ -375,6 +375,18 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- 水平+垂直滚动+首行首列固定+翻页Listview样例 -->
|
||||
<activity
|
||||
android:name=".sample.fixed.HVScorllListviewActivity"
|
||||
android:label="@string/HVScorllListviewActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="stateAlwaysHidden|adjustResize" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="com.zftlive.android.SAMPLE_CODE" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- 静态注册短信广播接收器 -->
|
||||
<receiver android:name=".sample.sms.SMSBroadcastReceiver">
|
||||
<intent-filter android:priority="2147483647">
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10dp"
|
||||
>
|
||||
<include
|
||||
android:id="@+id/head"
|
||||
layout="@layout/activity_hvscorll_listview_item" />
|
||||
|
||||
<com.zftlive.android.view.pulltorefresh.PullToRefreshListView
|
||||
xmlns:ptr="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/listView1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:cacheColorHint="@android:color/transparent"
|
||||
android:divider="@color/lightgray"
|
||||
android:dividerHeight="1.5dp"
|
||||
android:focusable="true"
|
||||
android:footerDividersEnabled="true"
|
||||
android:headerDividersEnabled="true"
|
||||
android:listSelector="@android:color/transparent"
|
||||
android:scrollbars="none"
|
||||
ptr:ptrAnimationStyle="rotate"
|
||||
>
|
||||
</com.zftlive.android.view.pulltorefresh.PullToRefreshListView>
|
||||
</LinearLayout>
|
|
@ -0,0 +1,237 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/demo_list_selector"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_zqmc"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<com.zftlive.android.view.ObserverHScrollViewIntercept
|
||||
android:id="@+id/scroollContainter"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toRightOf="@id/textView1"
|
||||
android:focusable="false" >
|
||||
|
||||
<com.zftlive.android.view.ObserverHScrollView
|
||||
android:id="@+id/horizontalScrollView1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false"
|
||||
android:scrollbars="none" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="false"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_zqjc"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_zqdm"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_fxjc"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView5"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_ksr"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView6"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_fxjg"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView7"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_sjfxze"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView8"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_jxfs"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView9"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_fxzq"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView10"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_pmll"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView11"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_lc"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView12"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_zjll"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView13"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_zqqx"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView14"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_zqpj"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView15"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_ztpj"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView16"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_zqpjjg"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView17"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_ztpjjg"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView18"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_zqzwdjr"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView19"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_ltr"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView20"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_jzghr"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView21"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_qxr"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView22"
|
||||
android:layout_width="@dimen/bond_table_header_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/bound_search_result_head_dqr"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="@dimen/bond_table_header_text" />
|
||||
</LinearLayout>
|
||||
</com.zftlive.android.view.ObserverHScrollView>
|
||||
</com.zftlive.android.view.ObserverHScrollViewIntercept>
|
||||
|
||||
</RelativeLayout>
|
|
@ -6,4 +6,11 @@
|
|||
<dimen name="line_point_size">6px</dimen>
|
||||
<!-- 曲线坐标轴刻度字体大小 -->
|
||||
<dimen name="axis_label_text">20sp</dimen>
|
||||
|
||||
<!-- 债券搜索结果表头字体大小 -->
|
||||
<dimen name="bond_table_header_text">16sp</dimen>
|
||||
<!-- 债券搜索结果表单元格大小 -->
|
||||
<dimen name="bond_table_cell_text">14sp</dimen>
|
||||
<!-- 债券搜索结果列表宽度 -->
|
||||
<dimen name="bond_table_header_width">140dp</dimen>
|
||||
</resources>
|
|
@ -19,6 +19,7 @@
|
|||
<string name="SMSOperationActivity">发送短信/拦截示例</string>
|
||||
<string name="BasicTestActivity">基本常用操作测试样例</string>
|
||||
<string name="DrawerLayoutActivity">DrawerLayout侧滑菜单</string>
|
||||
<string name="HVScorllListviewActivity">水平/垂直滚动+首行首列固定+翻页Listview</string>
|
||||
<!-- Android样例锦集label(结束) -->
|
||||
|
||||
<!-- 短信验证码/拦截示例(开始) -->
|
||||
|
@ -70,4 +71,28 @@
|
|||
<string name="drawer_open">打开</string>
|
||||
<!-- DrawerLayout抽屉菜单示例(结束) -->
|
||||
|
||||
<!-- 债券查询结果表头 -->
|
||||
<string name="bound_search_result_head_zqmc">债券名称</string>
|
||||
<string name="bound_search_result_head_zqjc">债券简称</string>
|
||||
<string name="bound_search_result_head_zqdm">债券代码</string>
|
||||
<string name="bound_search_result_head_fxjc">发行人简称</string>
|
||||
<string name="bound_search_result_head_ksr">发行日期</string>
|
||||
<string name="bound_search_result_head_fxjg">发行价格(元)</string>
|
||||
<string name="bound_search_result_head_sjfxze">实际发行总额(亿元)</string>
|
||||
<string name="bound_search_result_head_jxfs">计息方式</string>
|
||||
<string name="bound_search_result_head_fxzq">付息周期/付息频率</string>
|
||||
<string name="bound_search_result_head_pmll">票面利率(%)</string>
|
||||
<string name="bound_search_result_head_lc">利差(%)</string>
|
||||
<string name="bound_search_result_head_zjll">基准利率(%)</string>
|
||||
<string name="bound_search_result_head_zqqx">证券期限</string>
|
||||
<string name="bound_search_result_head_zqpj">信用评级一</string>
|
||||
<string name="bound_search_result_head_ztpj">信用评级二</string>
|
||||
<string name="bound_search_result_head_zqpjjg">评级机构一</string>
|
||||
<string name="bound_search_result_head_ztpjjg">评级机构二</string>
|
||||
<string name="bound_search_result_head_zqzwdjr">债券债务登记日</string>
|
||||
<string name="bound_search_result_head_ltr">交易流通起始日</string>
|
||||
<string name="bound_search_result_head_jzghr">交易流通终止日</string>
|
||||
<string name="bound_search_result_head_qxr">起息日</string>
|
||||
<string name="bound_search_result_head_dqr">兑付日</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -0,0 +1,379 @@
|
|||
package com.zftlive.android.sample.fixed;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.HorizontalScrollView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.zftlive.android.R;
|
||||
import com.zftlive.android.base.BaseActivity;
|
||||
import com.zftlive.android.tools.ToolAlert;
|
||||
import com.zftlive.android.tools.ToolDateTime;
|
||||
import com.zftlive.android.tools.ToolHTTP;
|
||||
import com.zftlive.android.tools.ToolNetwork;
|
||||
import com.zftlive.android.tools.ToolString;
|
||||
import com.zftlive.android.tools.http.JSONHandler;
|
||||
import com.zftlive.android.view.ObserverHScrollView;
|
||||
import com.zftlive.android.view.ObserverHScrollView.OnScrollChangedListener;
|
||||
import com.zftlive.android.view.pulltorefresh.PullToRefreshBase;
|
||||
import com.zftlive.android.view.pulltorefresh.PullToRefreshBase.Mode;
|
||||
import com.zftlive.android.view.pulltorefresh.PullToRefreshListView;
|
||||
|
||||
public class HVScorllListviewActivity extends BaseActivity {
|
||||
|
||||
/**列表表头容器**/
|
||||
private RelativeLayout mListviewHead;
|
||||
/**列表ListView**/
|
||||
private PullToRefreshListView mListView;
|
||||
/**列表ListView水平滚动条**/
|
||||
private HorizontalScrollView mHorizontalScrollView;
|
||||
/**列表适配器**/
|
||||
private BondSearchResultAdapter mListAdapter;
|
||||
/**上下文**/
|
||||
private Context mContext;
|
||||
/**总记录数**/
|
||||
private int totalRecordCount = 0;
|
||||
/**每一页请求条数**/
|
||||
private int mPerPageCount = 10;
|
||||
/***请求页码**/
|
||||
private int mPageNo = 1;
|
||||
/**是否加载完成**/
|
||||
private boolean isLoadFinished = true;
|
||||
|
||||
@Override
|
||||
public int bindLayout() {
|
||||
return R.layout.activity_hvscorll_listview;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView(View view) {
|
||||
|
||||
mContext = this;
|
||||
|
||||
//初始化列表表头
|
||||
mListviewHead = (RelativeLayout) findViewById(R.id.head);
|
||||
mListviewHead.setFocusable(true);
|
||||
mListviewHead.setClickable(true);
|
||||
mListviewHead.setBackgroundColor(getResources().getColor(R.color.table_header));
|
||||
mListviewHead.setOnTouchListener(mHeadListTouchLinstener);
|
||||
mListviewHead.setVisibility(View.GONE);
|
||||
mHorizontalScrollView = (HorizontalScrollView) mListviewHead.findViewById(R.id.horizontalScrollView1);
|
||||
|
||||
//实例化listview适配器
|
||||
mListAdapter = new BondSearchResultAdapter();
|
||||
|
||||
//初始化listview
|
||||
mListView = (PullToRefreshListView) findViewById(R.id.listView1);
|
||||
mListView.setMode(Mode.DISABLED);
|
||||
mListView.getLoadingLayoutProxy().setRefreshingLabel("正在加载..");
|
||||
mListView.getLoadingLayoutProxy().setReleaseLabel("释放刷新");
|
||||
mListView.setOnScrollListener(mListViewScrollListener);
|
||||
mListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
|
||||
|
||||
@Override
|
||||
public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
|
||||
mListView.getLoadingLayoutProxy(true,false).setPullLabel("下拉刷新");
|
||||
//下拉刷新
|
||||
if(isLoadFinished){
|
||||
requestData(1);
|
||||
mListView.getLoadingLayoutProxy().setLastUpdatedLabel("上次更新:"+ToolDateTime.formatDateTime(new Date(), "yyyy-MM-dd HH:mm"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
|
||||
mListView.getLoadingLayoutProxy(false,true).setPullLabel("加载更多");
|
||||
//上拉加载更多
|
||||
if(mListAdapter.getCount() < totalRecordCount && isLoadFinished){
|
||||
requestData(mListAdapter.getPageNo());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//获取到Listview
|
||||
ListView listview = mListView.getRefreshableView();
|
||||
listview.setOnTouchListener(mHeadListTouchLinstener);
|
||||
listview.setAdapter(mListAdapter);
|
||||
|
||||
//等待对话框
|
||||
requestData(1);
|
||||
mListView.getLoadingLayoutProxy().setLastUpdatedLabel("上次更新:"+ToolDateTime.formatDateTime(new Date(), "yyyy-MM-dd HH:mm"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doBusiness(Context mContext) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求数据
|
||||
*/
|
||||
private void requestData(int pageNo){
|
||||
|
||||
mPageNo = pageNo;
|
||||
|
||||
//判断网络状态
|
||||
if(ToolNetwork.getInstance().init(getApplicationContext()).isConnected()){
|
||||
//正在加载
|
||||
isLoadFinished = false;
|
||||
try {
|
||||
ToolAlert.closeLoading();
|
||||
//弹出加载对话框
|
||||
ToolAlert.showLoading(this, "加载中,请稍后...",new ToolAlert.ILoadingOnKeyListener(){
|
||||
@Override
|
||||
public boolean onKey(DialogInterface dialog, int keyCode,KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
dialog.dismiss();
|
||||
ToolHTTP.client.cancelAllRequests(true);//取消网络请求
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
this.finish();
|
||||
Log.e(TAG, e.getMessage());
|
||||
return;
|
||||
}
|
||||
// 请求查询数据
|
||||
|
||||
}else{
|
||||
//刷新完成
|
||||
isLoadFinished = true;
|
||||
mListView.onRefreshComplete();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 债券查询回调Handler
|
||||
*/
|
||||
private JSONHandler mBondQueryHandler = new JSONHandler() {
|
||||
@Override
|
||||
public void success(final JSONObject jsonObject) {
|
||||
try {
|
||||
// 错误信息
|
||||
String errorMessage = jsonObject.getString("errorMsg");
|
||||
if (ToolString.isNoBlankAndNoNull(errorMessage))
|
||||
{
|
||||
// 获取数据
|
||||
JSONArray dataList = jsonObject.getJSONArray("dataList");
|
||||
//下拉刷新情况
|
||||
if(mPageNo == 1){
|
||||
mListAdapter.clear();
|
||||
}
|
||||
for (int i = 0; i < dataList.length(); i++) {
|
||||
mListAdapter.addItem(dataList.getJSONObject(i));
|
||||
Log.e(TAG, mListAdapter.getPageNo() + "-->i "+dataList.getJSONObject(i).optString("zqdm"));
|
||||
}
|
||||
//列头可见
|
||||
mListviewHead.setVisibility(View.VISIBLE);
|
||||
//通知更新数据
|
||||
mListAdapter.notifyDataSetChanged();
|
||||
//结果集中记录数 TODO
|
||||
totalRecordCount = jsonObject.optInt("dataCount",dataList.length());
|
||||
//刷新完成
|
||||
isLoadFinished = true;
|
||||
mListView.onRefreshComplete();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, e.getMessage().toString());
|
||||
//刷新完成
|
||||
isLoadFinished = true;
|
||||
mListView.onRefreshComplete();
|
||||
}
|
||||
|
||||
// 关闭等待对话框
|
||||
ToolAlert.closeLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failure(int statusCode, String responseBody, Throwable e) {
|
||||
Log.e(TAG, e.getMessage().toString());
|
||||
//刷新完成
|
||||
isLoadFinished = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 列头/Listview触摸事件监听器<br>
|
||||
* 当在列头 和 listView控件上touch时,将这个touch的事件分发给 ScrollView
|
||||
*/
|
||||
private View.OnTouchListener mHeadListTouchLinstener = new View.OnTouchListener(){
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
mHorizontalScrollView.onTouchEvent(event);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* listView滚动监听器
|
||||
*/
|
||||
private AbsListView.OnScrollListener mListViewScrollListener = new AbsListView.OnScrollListener() {
|
||||
@Override
|
||||
/**
|
||||
* firstVisibleItem 当前页第一条记录的索引
|
||||
* visibleItemCount 当前页可见条数
|
||||
* totalItemCount 已加载总记录数
|
||||
**/
|
||||
public void onScroll(AbsListView view, int firstVisibleItem,
|
||||
int visibleItemCount, int totalItemCount) {
|
||||
if (visibleItemCount > 0
|
||||
&& firstVisibleItem + visibleItemCount == totalItemCount
|
||||
&& totalRecordCount > totalItemCount && isLoadFinished) {
|
||||
requestData(mListAdapter.getPageNo());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 债券查询列表适配器
|
||||
*/
|
||||
public class BondSearchResultAdapter extends com.zftlive.android.base.BaseAdapter{
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
// 查找控件
|
||||
ViewHolder holder = null;
|
||||
if (null == convertView) {
|
||||
convertView = LayoutInflater.from(mContext).inflate(R.layout.activity_hvscorll_listview_item, null);
|
||||
holder = new ViewHolder();
|
||||
|
||||
holder.txt1 = (TextView) convertView.findViewById(R.id.textView1);
|
||||
holder.txt2 = (TextView) convertView.findViewById(R.id.textView2);
|
||||
holder.txt3 = (TextView) convertView.findViewById(R.id.textView3);
|
||||
holder.txt4 = (TextView) convertView.findViewById(R.id.textView4);
|
||||
holder.txt5 = (TextView) convertView.findViewById(R.id.textView5);
|
||||
holder.txt6 = (TextView) convertView.findViewById(R.id.textView6);
|
||||
holder.txt7 = (TextView) convertView.findViewById(R.id.textView7);
|
||||
holder.txt8 = (TextView) convertView.findViewById(R.id.textView8);
|
||||
holder.txt9 = (TextView) convertView.findViewById(R.id.textView9);
|
||||
holder.txt10 = (TextView) convertView.findViewById(R.id.textView10);
|
||||
holder.txt11 = (TextView) convertView.findViewById(R.id.textView11);
|
||||
holder.txt12 = (TextView) convertView.findViewById(R.id.textView12);
|
||||
holder.txt13 = (TextView) convertView.findViewById(R.id.textView13);
|
||||
holder.txt14 = (TextView) convertView.findViewById(R.id.textView14);
|
||||
holder.txt15 = (TextView) convertView.findViewById(R.id.textView15);
|
||||
holder.txt16 = (TextView) convertView.findViewById(R.id.textView16);
|
||||
holder.txt17 = (TextView) convertView.findViewById(R.id.textView17);
|
||||
holder.txt18 = (TextView) convertView.findViewById(R.id.textView18);
|
||||
holder.txt19 = (TextView) convertView.findViewById(R.id.textView19);
|
||||
holder.txt20 = (TextView) convertView.findViewById(R.id.textView20);
|
||||
holder.txt21 = (TextView) convertView.findViewById(R.id.textView21);
|
||||
holder.txt22 = (TextView) convertView.findViewById(R.id.textView22);
|
||||
//列表水平滚动条
|
||||
ObserverHScrollView scrollView1 = (ObserverHScrollView) convertView.findViewById(R.id.horizontalScrollView1);
|
||||
holder.scrollView = (ObserverHScrollView) convertView.findViewById(R.id.horizontalScrollView1);
|
||||
//列表表头滚动条
|
||||
ObserverHScrollView headSrcrollView = (ObserverHScrollView) mListviewHead.findViewById(R.id.horizontalScrollView1);
|
||||
headSrcrollView.AddOnScrollChangedListener(new OnScrollChangedListenerImp(scrollView1));
|
||||
|
||||
convertView.setTag(holder);
|
||||
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
// 装填数据
|
||||
JSONObject data = (JSONObject) getItem(position);
|
||||
try {
|
||||
holder.txt1.setText(data.optString("zqmc"));
|
||||
holder.txt2.setText(data.optString("zqjc"));
|
||||
holder.txt3.setText(data.optString("zqdm"));
|
||||
holder.txt4.setText(data.optString("fxjc"));
|
||||
holder.txt5.setText(data.optString("ksr"));
|
||||
holder.txt6.setText(data.optString("fxjg"));
|
||||
holder.txt7.setText(data.optString("sjfxze"));
|
||||
holder.txt8.setText(data.optString("jxfs"));
|
||||
holder.txt9.setText(data.optString("fxzq"));
|
||||
holder.txt10.setText(data.optString("pmll"));
|
||||
holder.txt11.setText(data.optString("lc"));
|
||||
holder.txt12.setText(data.optString("zjll"));
|
||||
holder.txt13.setText(data.optString("zqqx"));
|
||||
holder.txt14.setText(data.optString("zqpj"));
|
||||
holder.txt15.setText(data.optString("ztpj"));
|
||||
holder.txt16.setText(data.optString("zqpjjg"));
|
||||
holder.txt17.setText(data.optString("ztpjjg"));
|
||||
holder.txt18.setText(data.optString("zqzwdjr"));
|
||||
holder.txt19.setText(data.optString("ltr"));
|
||||
holder.txt20.setText(data.optString("jzghr"));
|
||||
holder.txt21.setText(data.optString("qxr"));
|
||||
holder.txt22.setText(data.optString("dqr"));
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, e.getMessage().toString());
|
||||
}
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
private class OnScrollChangedListenerImp implements OnScrollChangedListener {
|
||||
ObserverHScrollView mScrollViewArg;
|
||||
|
||||
public OnScrollChangedListenerImp(ObserverHScrollView scrollViewar) {
|
||||
mScrollViewArg = scrollViewar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollChanged(int l, int t, int oldl, int oldt) {
|
||||
mScrollViewArg.smoothScrollTo(l, t);
|
||||
}
|
||||
};
|
||||
|
||||
private class ViewHolder {
|
||||
TextView txt1;
|
||||
TextView txt2;
|
||||
TextView txt3;
|
||||
TextView txt4;
|
||||
TextView txt5;
|
||||
TextView txt6;
|
||||
TextView txt7;
|
||||
TextView txt8;
|
||||
TextView txt9;
|
||||
TextView txt10;
|
||||
TextView txt11;
|
||||
TextView txt12;
|
||||
TextView txt13;
|
||||
TextView txt14;
|
||||
TextView txt15;
|
||||
TextView txt16;
|
||||
TextView txt17;
|
||||
TextView txt18;
|
||||
TextView txt19;
|
||||
TextView txt20;
|
||||
TextView txt21;
|
||||
TextView txt22;
|
||||
HorizontalScrollView scrollView;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
package com.zftlive.android.view;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.HorizontalScrollView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
/*
|
||||
* 自定义的 滚动控件
|
||||
* 重载了 onScrollChanged(滚动条变化),监听每次的变化通知给 观察(此变化的)观察者
|
||||
* 可使用 AddOnScrollChangedListener 来订阅本控件的 滚动条变化
|
||||
* */
|
||||
public class ObserverHScrollView extends HorizontalScrollView {
|
||||
ScrollViewObserver mScrollViewObserver = new ScrollViewObserver();
|
||||
|
||||
public ObserverHScrollView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
public ObserverHScrollView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public ObserverHScrollView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
Log.i("ObserverHScrollView","MyHScrollView onTouchEvent");
|
||||
return super.onTouchEvent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
|
||||
/*
|
||||
* 当滚动条移动后,引发 滚动事件。通知给观察者,观察者会传达给其他的。
|
||||
*/
|
||||
if (mScrollViewObserver != null /*&& (l != oldl || t != oldt)*/) {
|
||||
mScrollViewObserver.NotifyOnScrollChanged(l, t, oldl, oldt);
|
||||
}
|
||||
super.onScrollChanged(l, t, oldl, oldt);
|
||||
}
|
||||
|
||||
/*
|
||||
* 订阅 本控件 的 滚动条变化事件
|
||||
* */
|
||||
public void AddOnScrollChangedListener(OnScrollChangedListener listener) {
|
||||
mScrollViewObserver.AddOnScrollChangedListener(listener);
|
||||
}
|
||||
|
||||
/*
|
||||
* 取消 订阅 本控件 的 滚动条变化事件
|
||||
* */
|
||||
public void RemoveOnScrollChangedListener(OnScrollChangedListener listener) {
|
||||
mScrollViewObserver.RemoveOnScrollChangedListener(listener);
|
||||
}
|
||||
|
||||
/*
|
||||
* 当发生了滚动事件时
|
||||
*/
|
||||
public static interface OnScrollChangedListener {
|
||||
public void onScrollChanged(int l, int t, int oldl, int oldt);
|
||||
}
|
||||
|
||||
/*
|
||||
* 观察者
|
||||
*/
|
||||
public static class ScrollViewObserver {
|
||||
List<OnScrollChangedListener> mList;
|
||||
|
||||
public ScrollViewObserver() {
|
||||
super();
|
||||
mList = new ArrayList<OnScrollChangedListener>();
|
||||
}
|
||||
|
||||
public void AddOnScrollChangedListener(OnScrollChangedListener listener) {
|
||||
mList.add(listener);
|
||||
}
|
||||
|
||||
public void RemoveOnScrollChangedListener(
|
||||
OnScrollChangedListener listener) {
|
||||
mList.remove(listener);
|
||||
}
|
||||
|
||||
public void NotifyOnScrollChanged(int l, int t, int oldl, int oldt) {
|
||||
if (mList == null || mList.size() == 0) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < mList.size(); i++) {
|
||||
if (mList.get(i) != null) {
|
||||
mList.get(i).onScrollChanged(l, t, oldl, oldt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.zftlive.android.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
/*
|
||||
*
|
||||
* 一个视图容器控件
|
||||
* 阻止 拦截 ontouch事件传递给其子控件
|
||||
* */
|
||||
public class ObserverHScrollViewIntercept extends LinearLayout {
|
||||
|
||||
public ObserverHScrollViewIntercept(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public ObserverHScrollViewIntercept(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
Log.i("pdwy","ScrollContainer onInterceptTouchEvent");
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue