android, PullToRefreshListView up pull, down pull distinguish |
public class MainActivity extends Activity {
private PullToRefreshListView mPtrlv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView( R.layout.activity_main );
initListView();
}
private Handler mHandler = new Handler();
private Runnable mRunnable = new Runnable() {
@Override
public void run() {
mPtrlv.onRefreshComplete();
}
};
private void initListView(){
mPtrlv = (PullToRefreshListView) findViewById( R.id.cardlist );
mPtrlv.setOnRefreshListener( new OnRefreshListener2<ListView>() {
@Override
public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
waitAndFinishRefresh();
}
@Override
public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
waitAndFinishRefresh();
}
});
}
private void waitAndFinishRefresh(){
new Thread( new Runnable() {
@Override
public void run() {
try{
Thread.sleep( 2000 );
mHandler.post( mRunnable );
} catch( Exception e ){ }
}
}).start();
}
}
'프로그래밍 놀이터 > 안드로이드, Java' 카테고리의 다른 글
[android] up navigation using NavUtils cause onCreate() of parent activity. (1) | 2014.02.27 |
---|---|
[android] PagerTitleStrip example (0) | 2014.02.26 |
[android] webview 의 링크에 따라 다른 action 취하도록 하기 (0) | 2014.02.24 |
[android] 왜 MediaStore.ACTION_VIDEO_CAPTURE 를 실행하면 activity 의 oncreate 가 다시 불리는가? (1) | 2014.02.23 |
[android] Linkify 를 이용하여 TextView 에 link 주기 (0) | 2014.02.20 |
댓글