代码拉取完成,页面将自动刷新
1.在项目根目录下的build.gradle文件中,
allprojects {
repositories {
maven {
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
}
}
}
2.在entry模块的build.gradle文件中,
dependencies {
implementation('com.gitee.chinasoft_ohos:MultipleStatueView:1.0.0')
}
在sdk6,DevEco Studio 2.2 Beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
<com.example.multiple_status_view
ohos:id="$+id:multiple_status_view"
ohos:width="match_parent"
ohos:height="match_parent"
ohos:loadingView="$layout:custom_loading_view"
ohos:emptyView="$layout:custom_empty_view"
ohos:errorView="$layout:custom_error_view"
ohos:noNetworkView="$layout:custom_no_network_view"
ohos:contentView="$layout:main_content"/>
MultipleStatusView multipleStatusView = (MultipleStatusView) findViewById(ResourceTable.Id_multiple_status_view);
//显示加载中视图
multipleStatusView.showLoading();
// mMultipleStatusView.showLoading("自定义提示内容");
// mMultipleStatusView.showLoading(ResourceTable.String_custom_hint_content, "占位符1", "占位符2", "...");
// multipleStatusView.showLoading(ResourceTable.Layout_xxx, layoutParams);
// multipleStatusView.showLoading(customView, layoutParams);
//显示空视图
multipleStatusView.showEmpty(ResourceTable.Id_empty_retry_view);
// mMultipleStatusView.showEmpty("自定义提示内容",ResourceTable.Id_empty_retry_view);
// mMultipleStatusView.showEmpty(ResourceTable.String_custom_hint_content, ResourceTable.Id_empty_retry_view,"占位符1", "占位符2", "...");
// multipleStatusView.showEmpty(ResourceTable.Layout_xxx, layoutParams,ResourceTable.Id_empty_retry_view);
// multipleStatusView.showEmpty(customView, layoutParams,ResourceTable.Id_empty_retry_view);
//显示错误视图
multipleStatusView.showError(ResourceTable.Id_error_retry_view);
// mMultipleStatusView.showError("自定义提示内容",ResourceTable.Id_error_retry_view);
// mMultipleStatusView.showError(ResourceTable.String_custom_hint_content, ResourceTable.Id_error_retry_view,"占位符1", "占位符2", "...");
// multipleStatusView.showError(ResourceTable.Layout_xxx, layoutParams,ResourceTable.Id_error_retry_view);
// multipleStatusView.showError(customView, layoutParams,ResourceTable.Id_error_retry_view);
//显示无网络视图
multipleStatusView.showNoNetwork(ResourceTable.Id_no_network_retry_view);
// mMultipleStatusView.showNoNetwork("自定义提示内容");
// mMultipleStatusView.showNoNetwork(ResourceTable.String_custom_hint_content,ResourceTable.Id_no_network_retry_view, "占位符1", "占位符2", "...");
// multipleStatusView.showNoNetwork(ResourceTable.Layout_xxx, layoutParams,ResourceTable.Id_no_network_retry_view);
// multipleStatusView.showNoNetwork(customView, layoutParams,ResourceTable.Id_no_network_retry_view);
//显示内容视图
multipleStatusView.showContent();
// multipleStatusView.showContent(ResourceTable.Layout_xxx, layoutParams);
// multipleStatusView.showContent(customView, layoutParams);
//设置重试视图点击事件
multipleStatusView.setOnRetryClickListener(onRetryClickListener);
//设置视图状态切换监听事件
mMultipleStatusView.setOnViewStatusChangeListener(OnViewStatusChangeListener);
/**
* 获取当前view的状态
* MultipleStatusView.STATUS_LOADING //当前为加载中视图
* MultipleStatusView.STATUS_EMPTY //当前为空视图
* MultipleStatusView.STATUS_ERROR //当前为错误视图
* MultipleStatusView.STATUS_NO_NETWORK//当前为无网络视图
* MultipleStatusView.STATUS_CONTENT //当前为内容视图
*/
int viewStatus = multipleStatusView.getViewStatus();
MultipleStatusView
继承自 DependentLayout
,所以内容视图也可以直接写在 MultipleStatusView
内部
<com.example.multiple_status_view
ohos:id="$+id:multiple_status_view"
ohos:width="match_parent"
ohos:height="match_parent"
ohos:emptyView="$layout:custom_empty_view"
ohos:errorView="$layout:custom_error_view"
ohos:loadingView="$layout:custom_loading_view"
ohos:noNetworkView="$layout:custom_no_network_view">
<Image
ohos:id="$+id:image"
ohos:width="60vp"
ohos:height="60vp"
ohos:center_in_parent="true"
ohos:left_margin="24vp"
ohos:right_margin="16vp"
ohos:image_src="$media:test"/>
<Text
ohos:id="$+id:text1"
ohos:width="match_content"
ohos:height="match_content"
ohos:align_top="@id/image"
ohos:right_of="@id/image"
ohos:text="内容视图111111"/>
<Text
ohos:width="match_content"
ohos:height="match_content"
ohos:align_bottom="@id/image"
ohos:right_of="@id/image"
ohos:text="内容视图222222"/>
</com.example.multiple_status_view>
注意事项
必须按如下规则设置对应视图根节点的
view id
,否则会导致试图重叠
ohos:emptyView="$layout:..."
ohos:errorView="$layout:..."
ohos:loadingView="$layout:..."
ohos:noNetworkView="$layout:..."
需要设置:
loading_view
empty_view
error_view
no_network_view
status_hint_content
view
进行重试, 需要设置:empty_retry_view
error_retry_view
no_network_retry_view
new
关键字创建自定义视图时,请设置 id
TextView tv = new TextView(getApplicationContext());
tv.setId(Utils.generateViewId());
tv.setText(text);
CodeCheck代码测试无异常
CloudTest代码测试无异常
病毒安全检测通过
当前版本demo功能与原组件基本无差异
1.0.0
Copyright 2015 classic
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型