![](https://s5-media.51cto.com/ost/pc/static/noavatar.gif)
回复
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
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:alligator:4.1.1')
annotationProcessor('com.gitee.chinasoft_ohos:alligator:4.1.1')
implementation('com.gitee.chinasoft_ohos:alligator-compiler:4.1.1')
annotationProcessor('com.gitee.chinasoft_ohos:alligator-compiler:4.1.1')
......
}
在sdk6,DevEco Studio2.2 beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
参照安装教程
创建Fraction切片页面,并在getContainerId()
public class TabFraction extends MiFraction {
@Override
protected Component onComponentAttached(LayoutScatter scatter, ComponentContainer container, Intent intent) {
return component;
}
@Override
public void setInitialFragmentIfRequired() {
}
}
创建切片页面绑定的的screen,继承自Screen类并实现序列化
public class TabScreen extends Screen implements Serializable {
private String mName;
public TabScreen(String name, int mContainerId, String group) {
super(mContainerId, group);
this.mName = name;
}
public String getmName() {
return mName;
}
}
使用注解将TabScreen与TabFraction进行绑定
@RegisterScreen(TabScreen.class)
public class TabFraction extends MiFraction {
......
}
继承Screen类
public class MainScreen extends Screen {
public MainScreen(int mContainerId, String group) {
super(mContainerId, group);
}
}
在AbilityPackage中初始化配置参数
public class SampleApplication extends AbilityPackage {
private static OhosNavigator sOhosNavigator;
@Override
public void onInitialize() {
super.onInitialize();
sOhosNavigator = new OhosNavigator(new GeneratedNavigationFactory());
}
public static Navigator getNavigator() {
return sOhosNavigator;
}
}
页面跳转方式:
private Navigator mNavigator = SampleApplication.getNavigator();
mNavigator.goForward();//跳转新页面
mNavigator.replace();//替换当前页面
mNavigator.reset();//重置当前栈
mNavigator.goBack();//回退
mNavigator.finishTopLevel();//关闭所有
CodeCheck代码测试无异常
CloudTest代码测试无异常
病毒安全检测通过
当前版本demo功能与原组件基本无差异
The MIT License (MIT)
Copyright (c) 2017 Artur Artikov
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.