# MultiStateView **Repository Path**: eachann_lee/MultiStateView ## Basic Information - **Project Name**: MultiStateView - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-05-07 - **Last Updated**: 2024-12-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MultiStateView [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-MultiStateView-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/1726) Android View that displays different content based on its state.
Based off of [Kennyc1012/MultiStateView](https://github.com/Kennyc1012/MultiStateView) The four different states the view can be in are: - Content - Empty - Error - Loading - NoNetwork ![screenshot](art/content.png) ![screenshot](art/loading.png) ![screenshot](art/empty.png) ![screenshot](art/error.png) ![screenshot](art/nonetwork.png) # Using MultiStateView MultiStateView can be used the same as any other view by adding it as a layout file via XML ```xml ``` The attributes to set for MultiStateView are ```xml ``` `msv_loadingView` is the view to be used for `VIEW_STATE_LOADING`
`msv_emptyView` is the view to be used for `VIEW_STATE_EMPTY`
`msv_errorView` is the view to be used for `VIEW_STATE_ERROR`
`msv_noNetworkView` is the view to be used for `VIEW_STATE_NO_NETWORK`
`msv_viewState` is the [ViewState](https://gitee.com/eachann_lee/MultiStateView/blob/master/library/src/main/java/com/kennyc/view/MultiStateView.kt#L23) for the MultiStateView
`msv_animateViewChanges` is a flag to set whether the views should animate in and out when switching states. `false` by default
`VIEW_STATE_CONTENT` is determined by whatever is inside of the tags via XML. NOTE a Content view must be set for the view to function, this is by design. To switch the state of MultiStateView, simply call ```kotlin multiStateView.viewState = state: ViewState ``` or in java ```java multiStateView.setViewState(@NonNull ViewState state) ``` You can also get the View for the accompanying ViewState by calling ```kotlin multiStateView.getView(state: ViewState):View? ``` or in java ```java @Nullable public View getView(@NonNull ViewState state) ``` # Including in your project To include MultiStateView in your project, make the following changes to your build.gradle file ## Add repository ```groovy repositories { maven { url 'https://jitpack.io' } } ``` ## Add dependency ```groovy dependencies { implementation 'com.gitee.eachann_lee:MultiStateView:2.1.3' } ``` # Contribution Pull requests are welcomed and encouraged. If you experience any bugs, please file an [issue](https://gitee.com/eachann_lee/MultiStateView/issues) License ======= Copyright 2015 Kenny Campagna 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 http://www.apache.org/licenses/LICENSE-2.0 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.