public class TableDetalPager extends MenuDetalBassPager {
/*初始化布局*/
private RefreshListview listview;
public View initView() {
View view=View.inflate(context, R.layout.tabletail_pager,null);
/*实例化tabletail_pager.xml
* */
listview=(RefreshListview)view.findViewById(R.id.listview);
}
}
package android.pims.com.beijingnews.view;
import android.content.Context;
import android.pims.com.beijingnews.R;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
public class RefreshListview extends ListView {
/*
* 下拉刷新和顶部轮播图
* */
private LinearLayout headerView;
/*
* 实例化下拉刷新控件
* */
private View ll_pull_drown_refresh;
private ImageView iv_arrow;
private ProgressBar pb_status;
private TextView tv_status;
private TextView tv_time;
public RefreshListview(Context context) {
this(context,null);
}
public RefreshListview(Context context, AttributeSet attrs) {
this(context, attrs,0);
}
public RefreshListview(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initHeaderView(context);
}
private void initHeaderView(Context context) {
headerView= (LinearLayout) View.inflate(context,R.layout.refresh_header,null);
/*
* 实例化下拉刷新控件
* */
ll_pull_drown_refresh= headerView.findViewById(R.id.ll_pull_drown_refresh);
iv_arrow=(ImageView) headerView.findViewById(R.id.iv_arrow);
pb_status=(ProgressBar)headerView.findViewById(R.id.pb_status);
tv_status=(TextView) headerView.findViewById(R.id.tv_status);
tv_time=(TextView) headerView.findViewById(R.id.tv_time);
//添加ListView的头
addHeaderView(headerView);
}
}
布局文件定义
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ProgressBar
android:indeterminateDrawable="@drawable/custom_progressbar"
android:layout_width="80dp"
android:layout_height="80dp" />
</LinearLayout>
@drawable/custom_progressbar"
<?xml version="1.0" encoding="utf-8"?>
<!--旋转0-360度-->
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegress="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
>
<!--android:useLevel="false" 持续显现
android:innerRadiusRatio="2.5" 内部环比例
android:thicknessRatio="15" 内部环厚度
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:innerRadiusRatio="2.5"
android:thicknessRatio="15"
android:useLevel="false"
>
<!--渐变-->
<gradient android:startColor="#ff0000"
android:centerColor="#88ff0000"
android:endColor="#ffffff"
android:type="sweep"></gradient>
</shape>
</rotate>