2

我有一个扩展相对布局的类。我在 viewpage 指示器的片段中调用这个类。

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
}
}

视图指示器工作正常。但问题是我无法在其中执行拉动刷新。布局不会向下移动,而且它只刷新一次。

4

0 回答 0