Android bottom navigation bar with numbers or red dots and online waiting to load animation examples

Android bottom navigation bar with numbers or red dots and online waiting animation

First, show the screenshot effect. The download address is at the end of the article

1、 Android bottom navigation bar with red dots

1. First write the interface view of the bottom navigation bar_ main_ tab.xml.

2. Modify the number in the bottom navigation bar in mainactivity

3. The bottom navigation bar in mainactivity needs to be modified in the fragment, so write some public methods in mainactivity.

4. Modify the bottom navigation bar in the fragment to get the main page, and call the modification method of the main page.

2、 Activity loads the animation.

1. For loading animation in activity, write a baseactivity. The layout is as follows

Note: ID is fl_ The FrameLayout of content contains a loading_ The layout of anim, which is the loading layout. There are three linear layouts in the loading layout. They are: loading layout, loading error layout and no data layout. If the loading fails, you need to click reload. The contents are as follows:

2. There are too many codes for baseactivity. Let's talk about the main. Rewrite the setcontentview method and put the new layout into the layout with ID fl_ In the layout of content, call getWindow (). setContentView(rootView); The rest is the same as an ordinary activity operation.

3. The new activity only needs to integrate baseactivity. When it needs to be loaded successfully, it calls loadsuccess() to put it. When the loading fails, it calls loaderror() to reload after the failure. It needs to call reloading() to reload and onrefresh() to reload the data. If there is no data, call nodata()

3、 The animation is loaded in the fragment, and the loading layout is put into the fragment. I don't have a good way to put forward basefragment for unified loading. There are some precautions.

1. When loading the layout of viewpager, it is better to preload the data of one screen.

2. Override the setuservisiblehint method in basefragment. Only when the fragment is visible can the data be loaded online.

3.fragment inherit BaseFragment needs to call the networking loading method in onViewCreated, because the setUserVisibleHint execution is relatively advanced, the page has not been added to the layout, and loading data will result in the failure of the filled data.

Download address: loadingproject_ jb51.rar

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>