Need help with multistateview?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

ydstar
128 Stars 31 Forks 9 Commits 0 Opened issues

Description

多视图组件,支持加载中,加载成功,加载失败,空数据等页面,支持自定义页面

Services available

!
?

Need anything else?

Contributors list

No Data

MultiViewKit

YdKit通用组件库

YdKit 是一组功能丰富的 Android 通用组件。

  • LogKit — 轻量级的 Android 日志系统。
  • RestfulKit — 简洁但不简单的 Android 网络组件库。
  • StorageKit — 高性能 Android 离线缓存框架。
  • ExecutorKit — 简洁易用的 Android 多线程操作框架。
  • CrashKit — 简洁易用的 Android Crash日志捕捉组件。
  • PermissionKit — 简洁易用的 Android 权限请求组件。
  • NavigationBarKit — 简洁易用的 Android 顶部导航条组件。
  • RefreshKit — 简洁易用的 Android 下拉刷新和上拉加载组件。
  • AdapterKit — 简洁易用的 Android 列表组件。
  • BannerKit — 简洁易用的 Android 无限轮播图组件。
  • MultiViewKit — 简洁易用的 Android 多视图组件。
  • TabBottomKit — 简洁易用的 Android 底部导航组件。

效果预览

动图演示效果

页面的多视图组件,支持自定义页面

导入方式

仅支持

AndroidX
dependencies {
     implementation 'com.android.ydkit:multiview-kit:1.0.0'
}

项目根目录build.gradle

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url = "https://dl.bintray.com/ydswifty/MultiViewKitRepo"
        }
    }
}

使用方法

1.在布局中添加MultiViewKit

<com.multiview.kit.multiviewkit android:id="@+id/multiViewKit" android:layout_width="match_parent" android:background="#eeeeee" android:layout_height="match_parent">

    <listview android:id="@+id/list" android:layout_width="match_parent" android:layout_height="match_parent" tools:listitem="@android:layout/simple_list_item_1"></listview>
</com.multiview.kit.multiviewkit>

</androidx.constraintlayout.widget.constraintlayout>

2.创建加载页面-空页面-错误页面,

加载页面 ```java public class LoadingView extends LinearLayout { public LoadingView(Context context) { this(context,null); }

public LoadingView(Context context, @Nullable AttributeSet attrs) {
    this(context, attrs,0);
}

public LoadingView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); LayoutInflater.from(context).inflate(R.layout.layout_state_loading, this, true); this.setOrientation(LinearLayout.VERTICAL); }

} ```

空页面 ```java public class EmptyView extends LinearLayout {

public EmptyView(Context context) {
    this(context,null);
}

public EmptyView(Context context, @Nullable AttributeSet attrs) { this(context, attrs,0); }

public EmptyView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); LayoutInflater.from(context).inflate(R.layout.layout_state_empty, this, true); this.setOrientation(LinearLayout.VERTICAL); }

}

错误页面
java public class ErrorView extends LinearLayout {
public ErrorView(Context context) {
    this(context,null);
}

public ErrorView(Context context, @Nullable AttributeSet attrs) { this(context, attrs,0); }

public ErrorView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); LayoutInflater.from(context).inflate(R.layout.layout_state_error, this, true); }

}

#### 3.把页面添加multiViewKit中,并设置其状态

//loading LoadingView loadingView = new LoadingView(context); multiViewKit.setViewForState(loadingView, VIEWSTATELOADING);

//空页面 EmptyView emptyView = new EmptyView(context); multiViewKit.setViewForState(emptyView, MultiViewKit.VIEWSTATEEMPTY);

//错误页面 mErrorView = new ErrorView(context); multiViewKit.setViewForState(mErrorView, VIEWSTATEERROR);

//默认开始展示加载页 multiViewKit.setViewState(VIEWSTATELOADING); ```

4.根据状态设置对应的页面

multiViewKit.setViewState(VIEW_STATE_CONTENT);

License

Copyright [2021] [ydStar]

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.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.