Implementation: "pull-down refresh" and prompt.
The package structure is as follows:
1. Modify MyScrollPane with the following key code:
VerticalScrollBar. addAdjustmentListener (new AdjustmentListener (){
Public void adjustmentValueChanged (AdjustmentEvent e ){
// The maximum value of the getMaximum () scroll bar is the maximum span.
// Visible size of getVisibleAmount ()
Int currentValue = getVerticalScrollBar (). getMaximum ()
-GetVerticalScrollBar (). getVisibleAmount ();
If (e. getValue () = currentValue &&! FriendTL. isLoading ()){
FriendTL. addPage ();
}
}
});
2. Modify the FriendTimeline and Timeline classes. key code:
Try {
If (lastId = Long. MAX_VALUE ){
StatusWapper = tm. getFriendsTimeline (0, 0,
New Paging (1 ));
} Else {
StatusWapper = tm. getFriendsTimeline (0, 0, lastId );
}
} Catch (WeiboException e ){
E. printStackTrace ();
}
Note:
StatusWapper = tm. getFriendsTimeline (0, 0, lastId); getFriendsTimeline (0, 0, lastI) in)
The method must be added to the Timeline API provided by Sina as follows:
Public StatusWapper getFriendsTimeline (Integer baseAPP, Integer feature, Long max_id) throws WeiboException {
Return Status. constructWapperStatus (Weibo. client. get (
WeiboConfig. getValue ("baseURL") + "statuses/friends_timeline.json ",
New PostParameter [] {
New PostParameter ("base_app", baseAPP. toString ()),
New PostParameter ("feature", feature. toString ()),
New PostParameter ("max_id", max_id.toString ())}));
}
3. added the TipDialog class as a prompt.
4. Modify the Main class and add fields.
Public static MainDialog mainDialog;
The running result is as follows:
Author: Cannel_2020