如何在viewpagerindicator中的相对布局中实现pulltorefresh?

时间:2013-03-22 04:56:35

标签: android viewpagerindicator

我有一个扩展相对布局的类。我在视图页面指示器的片段内调用此类。

public class rl_latest_news extends RelativeLayout 
private PullRefreshContainerView mContainerView;
private TextView mRefreshHeader;
{public rl_latest_news(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
        inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(R.layout.layout_latest_news, this, true);
mContainerView = (PullRefreshContainerView) findViewById(R.id.container1);
        mRefreshHeader = new TextView(context);
        mRefreshHeader.setLayoutParams(new LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        mRefreshHeader.setGravity(Gravity.CENTER);
        mRefreshHeader.setText(" Pull to refresh...");
        mContainerView.setRefreshHeader(mRefreshHeader);
        mContainerView.setOnChangeStateListener(new OnChangeStateListener() {
            public void onChangeState(PullRefreshContainerView container,
                    int state) {
                switch (state) {
                case PullRefreshContainerView.STATE_PULL:
                    mRefreshHeader.setText(" Pull to refresh ");
                    break;
                case PullRefreshContainerView.STATE_RELEASE:
                    mRefreshHeader.setText(" Release to refresh ");
                    break;              
                case PullRefreshContainerView.STATE_LOADING:{
                    mRefreshHeader.setText("Loading...");
                    new Thread(new Runnable() {
                        public void run() {
           //calling asynchronous task inside this
}
}

viewpage指标工作正常。但问题是我无法在其中实现pull刷新。布局不向下移动,也只刷新一次。

0 个答案:

没有答案