android自定义分页组件

本文介绍了Android中自定义分页组件PageControl的实现,包括初始化、按钮点击事件处理及分页监听器接口OnPageChangeListener的使用。示例展示了如何在ListView中应用此分页组件,实现分页效果。
摘要由CSDN通过智能技术生成
组件代码如下:
public class PageControl extends LinearLayout implements OnClickListener{
	private ImageButton firstImg;
	private ImageButton preImg;
	private ImageButton nextImg;
	private ImageButton endImg;
	private TextView totalPageText;
	private TextView curPageText;
	private int numPerPage=10;
	private int curPage=1;
	private int count=0;
	private OnPageChangeListener pageChangeListener; 
	public PageControl(Context context) {
		super(context);
		initPageComposite(context);
	}
	public PageControl(Context context, AttributeSet attrs) {
		super(context, attrs);
		initPageComposite(context);
	}
	public PageControl(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		initPageComposite(context);
	}
	private void initPageComposite(Context context){
		this.setPadding(5,5,5,5);
		firstImg=new ImageButton(context);
		firstImg.setId(1);
		firstImg.setImageResource(R.drawable.firstpage);
		firstImg.setPadding(0,0,0,0);
		LayoutParams layoutParam=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
		layoutParam.setMargins(0,0,5,0);
		firstImg.setLayoutParams(layoutParam);
		firstImg.setOnClickListener(this);
		this.addView(firstImg);
		preImg=new ImageButton(context);
		preImg.setId(2);
		preImg.setImageResource(R.drawable.prepage);
		preImg.setPadding(0,0,0,0);
		layoutParam=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutP
  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值