Android ListView FAQs and Usage Summary

Source: Internet
Author: User


first, the mechanismListView mechanism-Executes the GetCount first and then executes the GetView. If GetCount returns 0, does not execute Getviewgallery Convertview is not reused and returns null each time
second, the problem of collationListView The bottom item does not have a horizontal line (Divider)? The ListView layout is high using wrap_content and should be used Fill_parent

Remove the black line between rows and rows: List.setdivider (NULL);

Remember that the ListView height cannot be set to Wrap_content causes the entire page to refresh multiple times

Dynamically modify item Height-itemrootview.getlayoutparams (). height = Heightvalue; Attempt to use margin, child height is not valid
The Item root setting is highly invalid and can be resolved by setting the sub-view height. (The ListView Itemview sub-view set margin is invalid) two layers, the inner layer using margin, the outer use of framelayout invalidation, changed to linearlayout effective. For example, HTC G12 will fail.

Three, Common propertiesListView Item SelectorItem.xml the outer linearlayout is set selector.xml, the inner layer is set again Bakcground no effect is selected. Because the lower layer actually changed after the click, but was covered by the upper layer, it is common sense .... Click Parent view, whether the child view is selected, such as button
Remove the yellow background when selected
Android:listselector= "#00000000" android:listselector= "@null"//This setting is not valid


1. Whether to display scrollbar
2. Close the Overscroll, some phones overscroll have similar Fadingedge effect Listview.setoverscrollmode (view.over_scroll_never);
3. Remove the default black background when dragging:
Android:cachecolorhint= "#00000000"


5. The ListView automatically rolls to the bottom when refreshed:
List.setselection (Msglist.getadapter (). GetCount ()-1);

6. Remove the black shadow from the edge when the ListView slides to the top and bottom:
Android:fadingedge= "None"




* * Exception get item type starting with 0, with the following exception description, Getitemviewtype return type number more thanGetviewtypecount. The current exception isGetitemviewtype returns 3 types of IDs, whileGetviewtypecount = 2


java.lang.arrayindexoutofboundsexception:length=2; index=2
At Android.widget.abslistview$recyclebin.addscrapview (abslistview.java:7188)
At Android.widget.ListView.measureHeightOfChildren (listview.java:1338)
At Android.widget.ListView.onMeasure (listview.java:1238)
At Android.view.View.measure (view.java:15729)
At Android.view.ViewGroup.measureChildWithMargins (viewgroup.java:4854)
At Android.widget.LinearLayout.measureChildBeforeLayout (linearlayout.java:1404)
At Android.widget.LinearLayout.measureVertical (linearlayout.java:695)
At Android.widget.LinearLayout.onMeasure (linearlayout.java:588)
At Android.view.View.measure (view.java:15729)
At Android.widget.RelativeLayout.measureChildHorizontal (relativelayout.java:645)
At Android.widget.RelativeLayout.onMeasure (relativelayout.java:425)
At Android.view.View.measure (view.java:15729)
At Android.view.ViewGroup.measureChildWithMargins (viewgroup.java:4854)
At Android.widget.FrameLayout.onMeasure (framelayout.java:310)
At Android.view.View.measure (view.java:15729)
At Android.view.ViewGroup.measureChildWithMargins (viewgroup.java:4854)
At Android.widget.LinearLayout.measureChildBeforeLayout (linearlayout.java:1404)
At Android.widget.LinearLayout.measureVertical (linearlayout.java:695)
At Android.widget.LinearLayout.onMeasure (linearlayout.java:588)
At Android.view.View.measure (view.java:15729)
At Android.view.ViewGroup.measureChildWithMargins (viewgroup.java:4854)
At Android.widget.FrameLayout.onMeasure (framelayout.java:310)
At Com.android.internal.policy.impl.phonewindow$decorview.onmeasure (phonewindow.java:2344)
At Android.view.View.measure (view.java:15729)
At Android.view.ViewRootImpl.performMeasure (viewrootimpl.java:1948)
At Android.view.ViewRootImpl.measureHierarchy (viewrootimpl.java:1104)
At Android.view.ViewRootImpl.performTraversals (viewrootimpl.java:1300)
At Android.view.ViewRootImpl.doTraversal (viewrootimpl.java:1004)
At Android.view.viewrootimpl$traversalrunnable.run (viewrootimpl.java:4498)
At Android.view.choreographer$callbackrecord.run (choreographer.java:749)
At Android.view.Choreographer.doCallbacks (choreographer.java:562)
At Android.view.Choreographer.doFrame (choreographer.java:532)
At Android.view.choreographer$framedisplayeventreceiver.run (choreographer.java:735)
At Android.os.Handler.handleCallback (handler.java:725)
At Android.os.Handler.dispatchMessage (handler.java:92)
At Android.os.Looper.loop (looper.java:137)
At Android.app.ActivityThread.main (activitythread.java:5105)
At Java.lang.reflect.Method.invokeNative (Native Method)
At Java.lang.reflect.Method.invoke (method.java:511)
At Com.android.internal.os.zygoteinit$methodandargscaller.run (zygoteinit.java:793)
At Com.android.internal.os.ZygoteInit.main (zygoteinit.java:560)
At Dalvik.system.NativeStart.main (Native Method)


onscroll scrolling State judgmentOnscrolllistenerscroll_state_idle Slide and still
Scroll_state_fling finger off the screen, inertial sliding
Scroll_state_touch_scroll finger swipe on the screen
Test relatedCode in Activitythread, this code calls Onsaveinstancestate. Minstrumentation is responsible for invoking the on*** method Minstrumentation.callactivityonsaveinstancestate (r.activity, state);


Gridvie do not display scroll bars

Android:scrollbars= "None" with

Setverticalscrollbarenabled (TRUE);




Android ListView FAQs and Usage Summary

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.