YCStateLayout State Switching
0.2 Basic introduction
0.3 Case demonstration animation
- State switching, so that the View state switch and Activity completely separate. Using builder mode to freely add the required state View, can set data, data is empty, load data error, network error, load and other states, and support the layout of custom state. At present has been used in other formal projects, strong expansion!
1.An introduction to the switching State of Android Interface
1.1 Problems encountered in development
1.2 You can set up more than 5 state View
- How to switch the interface state?
- Some interfaces want to customize custom state?
- How does the state add a click event?
2.Train of thought change, extract separate class management several kinds of state
2.1 Previous practice：
- content interface view
- loading data view
- loading data error view
- no data after loading view
- no network view
2.2 Present practice：
- Directly include these interfaces into the main interface, then dynamically switch the interface, later found that this processing is not easy to reuse in other projects, and in activity to deal with the display and hiding of these states is messy
- Using the child class to inherit the parent property, write the switching state in the parent class, but what can some interfaces do if they do not inherit the parent class
3.An Analysis of the advantages of this State switching tool
- The switching of View states is completely separated from Activity. The View of these states must be encapsulated in a management class and several methods are exposed to implement the switching between View.
- The View that can be required varies from project to project, so consider designing the management class as an builder schema to freely add the required state View
4.1 Specific use
- Free to switch content, empty data, exception error, load, network error, etc.
- The parent class BaseActivity directly exposes the state in 5, making it easy for subclasses to uniformly manage state switching
- If some pages want to customize the state layout, they can also be implemented freely, simple
6.2 about 支付宝
- v1.0 Updated on 28 March 2017
- v1.1 Updated on 3 December 2017
- v1.1.5 Updated on 25 April 2018
- v1.1.6 Updated on November 15, 2018, updating targetSdkVersion to 27
6.3 About blog Summary links
6.4 About recommend
6.4 About LICENSE
- Great summary of blog notes, including Java basics and in-depth knowledge, Android technology blog, Python learning notes, and so on, but also includes the usual development of bug summary, of course, also collected a large number of interview questions after work. Long-term update, maintenance and revision, continuous improvement. Open source files are in markdown format!
- chained address ： https://github.com/yangchong211/YCBlogs
- If you feel good, you can star, thank you! Of course, you are also welcome to put forward suggestions, everything starts at a slight, quantitative change causes qualitative change!
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.