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,
Getfriendstimeline (0, 0,
Lasti)
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;
The running result is as follows:
Download Code:
Java Sina Weibo client development step 3 (micro disk)
Java Sina Weibo client development step 3 (csdn)
For more information, see:
Java Sina Weibo client development step 1
Java Sina Weibo client development step 2
For original works, please indicate the source for reprinting: All snails know