Java Sina Weibo client development step 3

Source: Internet
Author: User

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 ();

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.