<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > Android常用控件之下拉刷新Wifi列表

          Android常用控件之下拉刷新Wifi列表

          作者: 時(shí)間:2016-09-12 來源:網(wǎng)絡(luò) 收藏

          本文引用地址:http://www.ex-cimer.com/article/201609/304586.htm

          界面

          關(guān)鍵代碼

          下拉列表類

          package com.example.dropdownrefresh.ui;

          import java.text.SimpleDateFormat;

          import java.util.Date;

          import com.example.dropdownrefresh.R;

          import android.content.Context;

          import android.util.AttributeSet;

          import android.util.Log;

          import android.view.LayoutInflater;

          import android.view.MotionEvent;

          import android.view.View;

          import android.view.ViewGroup;

          import android.view.animation.LinearInterpolator;

          import android.view.animation.RotateAnimation;

          import android.widget.AbsListView;

          import android.widget.AbsListView.OnScrollListener;

          import android.widget.BaseAdapter;

          import android.widget.ImageView;

          import android.widget.LinearLayout;

          import android.widget.ListView;

          import android.widget.ProgressBar;

          import android.widget.TextView;

          /**

          * 下拉列表類

          * @author Administrator

          *

          */

          public class DropdownListView extends ListView implements OnScrollListener {

          private static final String TAG = listview;

          private final static int RELEASE_To_REFRESH = 0;

          private final static int PULL_To_REFRESH = 1;

          private final static int REFRESHING = 2;

          private final static int DONE = 3;

          private final static int LOADING = 4;

          // 實(shí)際的padding的距離與界面上偏移距離的比例

          private final static int RATIO = 3;

          private LayoutInflater inflater;

          private LinearLayout headView;

          private TextView tipsTextview;

          private TextView lastUpdatedTextView;

          private ImageView arrowImageView;

          private ProgressBar progressBar;

          private RotateAnimation animation;

          private RotateAnimation reverseAnimation;

          // 用于保證startY的值在一個(gè)完整的touch事件中只被記錄一次

          private boolean isRecored;

          private int headContentWidth;

          private int headContentHeight;

          private int startY;

          private int firstItemIndex;

          private int state;

          private boolean isBack;

          private OnRefreshListener refreshListener;

          private boolean isRefreshable;

          public DropdownListView(Context context) {

          super(context);

          // TODO Auto-generated constructor stub

          init(context);

          }

          public DropdownListView(Context context, AttributeSet attrs) {

          super(context, attrs);

          init(context);

          }

          private void init(Context context) {

          setCacheColorHint(context.getResources().getColor(R.color.transparent));

          inflater = LayoutInflater.from(context);

          headView = (LinearLayout) inflater.inflate(R.layout.head, null);

          arrowImageView = (ImageView) headView

          .findViewById(R.id.head_arrowImageView);

          arrowImageView.setMinimumWidth(70);

          arrowImageView.setMinimumHeight(50);

          progressBar = (ProgressBar) headView

          .findViewById(R.id.head_progressBar);

          tipsTextview = (TextView) headView.findViewById(R.id.head_tipsTextView);

          lastUpdatedTextView = (TextView) headView

          .findViewById(R.id.head_lastUpdatedTextView);

          measureView(headView);

          headContentHeight = headView.getMeasuredHeight();

          headContentWidth = headView.getMeasuredWidth();

          headView.setPadding(0, -1 * headContentHeight, 0, 0);

          headView.invalidate();

          Log.v(size, width: + headContentWidth + height:

          + headContentHeight);

          addHeaderView(headView, null, false);

          setOnScrollListener(this);

          animation = new RotateAnimation(0, -180,

          RotateAnimation.RELATIVE_TO_SELF, 0.5f,

          RotateAnimation.RELATIVE_TO_SELF, 0.5f);

          animation.setInterpolator(new LinearInterpolator());

          animation.setDuration(250);

          animation.setFillAfter(true);

          reverseAnimation = new RotateAnimation(-180, 0,

          RotateAnimation.RELATIVE_TO_SELF, 0.5f,

          RotateAnimation.RELATIVE_TO_SELF, 0.5f);

          reverseAnimation.setInterpolator(new LinearInterpolator());

          reverseAnimation.setDuration(200);

          reverseAnimation.setFillAfter(true);

          state = DONE;


          上一頁 1 2 3 4 5 下一頁

          關(guān)鍵詞:

          評(píng)論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();