!!!!! The android interface always displays the loading progress bar. Do not use ListFragment or android listfragment.

Source: Internet
Author: User

!!!!! The android interface always displays the loading progress bar. Do not use ListFragment or android listfragment.

Recently, the android application is almost finished, but some interfaces are defective and cannot be modified. The problem is as follows:

On the interface, the data has been loaded, but there is still a circular progress bar, it feels like it is always loading something, seriously affecting the appearance of the interface:

1. The layout uses LinearLayout.


2. The interface layout uses RelativeLayout.



All methods have been tried. Of course, they are all modified based on the layout file. What is fill_parent? alignBotton? For different layout methods? I tried all the attributes once, it took three days to solve this layout problem.

However, the layout file may have no problem.

Just calm down and think about it. Will the problem come from other places, not layout files?

Recalling the days when I was just learning Android, I wrote it according to the example in the book. I mentioned the part of ListView and the circular progress bar, so I opened the book and found the chapter, all of a sudden!



Pay attention to the underlined text in the photo: "A circular progress bar is displayed when ListView has no content?

Let's take a look at the ListView in this interface:

<? Xml version = "1.0" encoding = "UTF-8"?> <ScrollView xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "fill_parent" android: layout_height = "fill_parent"> <LinearLayout android: id = "@ + id/fragmentContainer" android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: orientation = "vertical"> <LinearLayout> <-- header, ignore --> </LinearLayout> <ListView android: id = "@ + id/list_uploadinfo_1" android: layout_width = "fill_parent" android: layout_height = "fill_parent" android: dividerHeight = "1px" android: divider = "# B8B8B8"> </ListView> <Button android: text = "map of the number of uploaded sites"/> <LinearLayout> <-- header, ignore --> </LinearLayout> <ListView android: id = "@ + id/list_uploadinfo_2" android: layout_width = "fill_parent" android: layout_height = "fill_parent" android: dividerHeight = "1px" android: divider = "# B8B8B8"> </ListView> <Button android: text = "Number of uploaded monthly trend Charts"/> </LinearLayout> </ScrollView>


 

Structure, there are two ListView, but they are all filled with data, there is no content problem.

Is there any other ListView? The answer is that there are other ListView, and the largest ListView is ignored by me:

Public class UploadInfoFragment extends ListFragment {// note that the ListFragmentprivate HashMap <String, Integer> monthQuantityMap; private HashMap <String, Integer> stationQuantityMap ;...}

It is to control the Fragment of this interface. It inherits the ListFragment and needs its own ListView to display the content, but only the two internal ListView just filled with the content, which is not big outside, so there will be this lingering circular progress bar !!!

What should we do? It's easy. Since you don't need to fill in data in this largest ListView, why use ListFragment? You can use a normal Fragment.

In fact, the ListFragment is used here because most of the Code is moved from other functions during this function, so the ListFragment is also moved.

Then modify the class to inherit the normal Fragment:

Public class UploadInfoFragment extends Fragment {// Note: Use a common Fragment to private HashMap <String, Integer> monthQuantityMap; private HashMap <String, Integer> stationQuantityMap ;...}
Finally, the annoying circular progress bar is removed and the problem is solved!




Summary: Some common problems can be found on the Internet at will, but these hidden problems are generally difficult to be directly found on the Internet, at this time, if you can read a book carefully, you may be pleasantly surprised to find out ~

In addition, when reading a book, it is better to take it seriously. In this way, some details can be printed in your mind and may be useful at any time ~



How many questions about Android? 1 fragment 2 listview 3 gridview

The landlord is too lazy to do it. These official APIs are all in it. Please give me a URL and learn it by yourself. Developer.android.com/guide/components/index.html


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: 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.