Do not know when you brush the microblog, have encountered, refresh too much, want to return to the top of the microblog before the situation. In fact, clicking on the top of the Actionbar can return to the top. Instead of always pulling down.
Don't say much, talk about how to do this in Android.
First, add a customview to Actionbar.
CustomView Layout file Actionbar_layout.xml:
1<?XML version= "1.0" encoding= "Utf-8"?> 2<LinearLayoutXmlns:android="Http://schemas.android.com/apk/res/android"3Android:id="@+id/ll_topbar"4Android:layout_width="Match_parent"5android:layout_height="Wrap_content"6android:orientation= "vertical" > 7 8 <textview 9 android:layout_width= "wrap_content" 10 android:layout_height=" Wrap_content " 11 android:layout_gravity= "center" 12 android:textcolor= "#000000" 13 android:id= "@+id/mytext" 14 android:textsize= "18SP"/>15 + </LINEARLAYOUT>
Then set Actionbar or load Custiomview to
1 ActionBar ActionBar = Getactionbar (); 2 actionbar.setdisplayoptions (Actionbar.display_show_custom); 3 Actionbar.setcustomview (r.layout.actionbar_layout);
1 View CustomView = layoutinflater. From (new LinearLayout (false); 2 Getactionbar (). setdisplayshowcustomenabled (3 Getactionbar (). Setcustomview (CustomView);
Finally, add the onclick event to Custiomview to enable the ListView to return to the top logic:
1 if (!mlistview.isstackfrombottom ()) {2 Mlistview.setstackfrombottom (TRUE); 3 }4 Mlistview.setstackfrombottom (false);
Http://www.tuicool.com/articles/6jEVze3
Android Learning--click Actionbar to implement the ListView to return to the top of