android resolves the listview conflict with scrollview, the height of the custom listview, and the Pull-down refresh

Source: Internet
Author: User
<span id="Label3"></p><p><p><strong><span style="font-size:14px; color:#33ccff; background-color:rgb(255,255,255)">Most of the time we need to use a ListView and nested use, then the problem comes, the ListView has its own</span></strong></p></p><p><p><strong><span style="font-size:14px; color:#33ccff; background-color:rgb(255,255,255)">Scroll bar, and nested inside the SCROLLVIEW. So a series of conflicts has been caused. The ListView is not displayed completely.</span></strong></p></p><p><p><strong><span style="font-size:14px; color:#33ccff; background-color:rgb(255,255,255)">Today gives a new pull-up refresh and conflict resolution SCENARIO.</span></strong></p></p><p><p><strong><span style="font-size:14px; color:#33ccff; background-color:rgb(255,255,255)">。 Click the download Drop-down to refresh the pull-up loader tool</span></strong></p></p><p><p><strong><span style="font-size:14px; color:#33ccff">After downloading the tool we copy and paste it into our own project, using the same way as custom VIEW. </span></strong></p></p><p><p><strong><span style="font-size:14px; color:#ff0000">Paste the code below</span></strong></p></p><textarea readonly name="code" class="java"> <framelayout android:layout_width= "match_parent" android:layout_height= "match_parent" Android:layout_bel ow= "@+id/toplin" > <com example= "" androidtool= "" viewtool= "" pulltorefreshview_all= "" android:id= "@+id/Pu Lltorefreshview "android:layout_width=" match_parent "android:layout_height=" match_parent "android:background=" # F4f4f4 "android:orientation=" Vertical "> <scrollview android:id=" @+id/scrollview "android:layout_width = "match_parent" android:layout_height= "match_parent" android:background= "#F4F4F4" > <linearlayout Android:layout_width= "match_parent" android:layout_height= "match_parent" android:orientation= "vertical" > <!--ad columns and strokes--<framelayout android:id= "@+id/framelayout" android:layout_width= "fill_parent" android:layout_height= "120dp" android:orientation= "vertical" > <com example= "ysh=" "view=" "bannerview=" "viewflow= "" android:id= "@+id/viewflow" android:layout_width= "fill_parent" android:layout_height= "110dp" > <framelayout android:layout_width= "fill_parent" android:layout_height= "35dp" android:layout_gravity= "bottom" android:background= "@color/transparent" android:gravity= "center" > <com example= "" Ysh = "view=" "bannerview=" "circleflowindicator=" "android:id=" @+id/viewflowindic "android:layout_width=" wrap_content "android:layout_height=" 30dp "android:layout_gravity=" center_horizontal|bottom "android:padding=" 1dip "app: activecolor= "#ff0000" app:activetype= "fill" app:circleseparation= "20dip" app:inactivecolor= "#ffffff" app: inactivetype= "fill" app:radius= "4dip" > </com></framelayout> </com></framelayout> <!--four buttons in the middle of the Landscape--<linearlayo UT android:id= "@+id/centerlayout" android:layout_width= "match_Parent "android:layout_height=" 68DP "android:layout_below=" @+id/framelayout "android:background=" #FFFFFF "android : orientation= "horizontal" > <linearlayout android:id= "@+id/mfindclinic" android:layout_wid Th= "0dp" android:layout_height= "wrap_content" android:layout_weight= "1" android:gravity= "center_horizontal" android:onclick= "opeselect" android:orientation= "vertical" > <imageview android:layout _width= "50dp" android:layout_height= "50dp" android:src= "@drawable/mfind1" > <textview Android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:text= "* * *" android:textalignment = "center" android:textcolor= "#333333" android:textsize= "15sp" > </textview></imagevi ew></linearlayout> <linearlayout android:id= "@+id/mfinddoctor" android:layout_width = "0dp" android:layout_height= "wrap_content" android:layout_weight= "1" android:gravity= "center_horizontal" android:onclick= "opeselect" android:orientation= "vertical" > <imageview android:layout_width= "50dp" android:layout_height= "50dp" android:src= "@drawable/mfind2 "> <textview android:layout_width=" wrap_content "android:layout_height=" wrap_content " android:text= "* * *" android:textalignment= "center" android:textcolor= "#333333" android:textsize= "15sp" > </textview></imageview></linearlayout> <linearlayout android:i d= "@+id/maskdoctor" android:layout_width= "0dp" android:layout_height= "wrap_content" android:layout_weight= "1" android:gravity= "center_horizontal" android:onclick= "opeselect" android:orientation= "vertical" > <imageview android:layout_width= "50dp" android:layout_height= "50dp" android:src= "@drawable/mfind3" > <textviewAndroid:layout_width= "wrap_content" android:layout_height= "wrap_content" android:text= "* * *" android:textalignment = "center" android:textcolor= "#333333" android:textsize= "15sp" > </textview></imagevi ew></linearlayout> <linearlayout android:id= "@+id/mcommunity" android:layout_width= "0dp" android:layout_height= "wrap_content" android:layout_weight= "1" android:gravity= "center_horizontal" android:o nclick= "opeselect" android:orientation= "vertical" > <imageview android:layout_width= "5 0DP "android:layout_height=" 50dp "android:src=" @drawable/mfind4 "> <textview android:l Ayout_width= "wrap_content" android:layout_height= "wrap_content" android:text= "community" android:textalignment= "center" android:textcolor= "#333333" android:textsize= "15sp" > </textview></imageview>< /linearlayout> </linearlayout> <linearlayout android:layout_width= "match_parent" android:layout_height= "match_parent" android: layout_marginleft= "5dp" android:layout_marginright= "5dp" android:layout_margintop= "5dp" > &lt ; ListView android:id= "@+id/main_list" android:layout_width= "match_parent" android:layout_height= "match_parent" android:scrollbars= "none" > </listview> </linearlayout> </linearlayout> </scrollview> &L T;progressbar android:id= "@+id/progressbar" android:layout_width= "wrap_content" android:layout_height= "wrap_ Content "android:layout_gravity=" Center "android:visibility=" gone "> </progressbar></com></ Framelayout></textarea><p><p><strong><span style="font-size:14px; color:#ff0000"><br>See the code paste as well as This. But we noticed that this time the ListView was wrapped in Scroll. Then the rolling up certainly not ... Next resolve this conflict issue.</span></strong></p></p><p><p><strong><span style="font-size:14px; color:#ff0000"><br>The following code</span></strong></p></p><textarea readonly name="code" class="java"><textarea readonly name= "code" class= "java" >//win Adapter and set Adapter adpater = new Main_goos_adapter (this, slist);//plus Load Adapter Main_list.setadapter (adpater);//set Adapter Setlistviewheight (main_list);//reset The location and Height//core custom setting height method/** * Dynamically set the height of the listview * * @param listview * Just throw a ListView and put it inside, isn't it simple to feel? */public static void Setlistviewheight (listView Listview) {if (listview = = Null) return; ListAdapter ListAdapter = Listview.getadapter ();//gets The adapter for the ListView if (listadapter = = Null) {return;} int totalheight = 0;//defines the height for (int i = 0; i < listadapter.getcount (); i++) {View listItem = Listadapter.getview (i, null , listView);//gets the value of a height of listitem.measure (0, 0);//gets measured totalheight + = listitem.getmeasuredheight ();//set Total height} Viewgroup.layoutparams params = listview.getlayoutparams ();p arams.height = totalheight+ (listview.getdividerheight () * (listadapter.getcount ()-1)); listview.setlayoutparams (params);//redraw height}//after reading Huanran dawu AH </textarea></textarea><p><p><strong><span style="font-size:14px; color:#ff0000"><br></span></strong></p></p><p><p><strong><span style="font-size:14px; color:#ff0000"><br>Then the problem is the origin of our top and bottom pull refresh hit ah. Take a look at the code</span></strong></p></p><textarea readonly name="code" class="java"><textarea readonly="" name="code" class="java">private Pulltorefreshview_all mpulltorefreshview;//drop-down Refresh box First declare the value//current activity to implement its two interfaces such as: Onheaderrefreshlisten er, Onfooterrefreshlistener Mpulltorefreshview = (pulltorefreshview_all) Findviewbyid (r.id.pulltorefreshview); Mpulltorefreshview.setonheaderrefreshlistener (this);//pull-down Load Mpulltorefreshview.setonfooterrefreshlistener (this) ;//pull up Refresh//and then implement its two methods, our dropdown can play up/** * drop-down refresh */@Overridepublic void Onheaderrefresh (pulltorefreshview_all V Iew) {dosomething ();} /** * pull-up loading */@Overridepublic void Onfooterrefresh (pulltorefreshview_all view) {}</textarea ></textarea></textarea><p><p><strong><span style="font-size:14px; color:#ff0000"><br></span></strong></p></p><p><p><strong><span style="font-size:14px; color:#ff0000"><br>So bob, learn to share together!!!</span></strong></p></p><p><p><strong><span style="font-size:14px; color:#ff0000"><br></span></strong></p></p><p><p><strong><br></strong></p></p><p><p><strong><br></strong></p></p><p><p><strong><br></strong></p></p><p><p><strong><br></strong></p></p><p><p><strong><br></strong></p></p><p><p><strong><br></strong></p></p><p><p><strong><br></strong></p></p><p><p><strong><br></strong></p></p><p><p>android resolves the listview conflict with scrollview, the height of the custom listview, and the Pull-down refresh</p></p></span>

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: info-contact@alibabacloud.com 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.