页面嵌套怎么做呢,想做个底部可切换tab的demo,
类似android的activity + viewpager + 多个fragment应该怎么搞啊?求大佬解惑。
页面嵌套
赞
收藏 0
回答 3
待解决
相关问题
应用的配置文件“config.json”中添加注释怎么做呢
3546浏览 • 2回复 待解决
应用侧显示华为云mqtt数据是怎么做?
3278浏览 • 1回复 待解决
同时安装多个DevEco Studio版本,怎么做让各个版本可以不冲突
1039浏览 • 1回复 已解决
PageAbility配合多个Slice实现页面间切换
8616浏览 • 4回复 已解决
工具类里 怎么跳转或打开页面呢?
387浏览 • 1回复 待解决
鸿蒙tablist 如何通过滑动切换页面?
1765浏览 • 1回复 待解决
使用ToggleButton切换图片时底部会有黑点出现
2286浏览 • 1回复 待解决
java鸿蒙Tab框架 image图片怎么渲染的
2296浏览 • 2回复 待解决
鸿蒙app开发 页面弹出了软键盘,底部的按钮被键盘挡住,有解决方案?
5182浏览 • 1回复 待解决
应用切换到后台再切换到前台总是在首页,没有进入上一次的操作页面
2565浏览 • 1回复 待解决
服务卡片如何跳转到指定的页面呢?
1387浏览 • 1回复 待解决
学鸿蒙做APP。开发分享微信的功能,怎么截图和调用微信分享呢
4214浏览 • 1回复 待解决
鸿蒙demo gradle报错怎么解决
5654浏览 • 4回复 待解决
JS如可开发一个可横向拖动的表格
2246浏览 • 1回复 待解决
鸿蒙要启动本机的一个service要如何做,有没有demo可以参考下
2660浏览 • 2回复 待解决
ScrollView嵌套ListContainer
2282浏览 • 5回复 待解决
鸿蒙js中,底部导航栏可以用自定义组件来做吗?
1747浏览 • 1回复 待解决
页面之间的跳转方式怎么设置的
1812浏览 • 1回复 待解决
怎么实现entry里的Slice切换到,feature里的Slice
2751浏览 • 2回复 待解决
想找些demo学习一下,比如各种样式的轮播图,吸顶效果的tab,沉浸式状态栏,赛贝尔曲线等等。
2682浏览 • 2回复 待解决
ob的ddl是怎么做的,如果几百个分区,那么一个ddl需要几百个分区全执行完才返回吗?
2187浏览 • 1回复 待解决
华为能不能做个快捷指令?
3749浏览 • 1回复 待解决
如何获得WebView页面的渲染或滚动时机呢
2252浏览 • 1回复 待解决
鸿蒙请求相册和相机的demo?
991浏览 • 1回复 待解决
hi3861 怎么编译点灯demo_link的代码并烧录
1811浏览 • 1回复 待解决
<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:orientation="vertical">
<DirectionalLayout
ohos:id="$+id:dl_frame"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:weight="1"/>
<DirectionalLayout
ohos:background_element="transparent"
ohos:height="match_content"
ohos:width="match_parent"
ohos:orientation="horizontal">
<DirectionalLayout
ohos:id="$+id:listtenDL"
ohos:height="match_content"
ohos:width="match_content"
ohos:top_margin="20vp"
ohos:background_element="#ffffff"
ohos:weight="1">
<Text
ohos:height="match_content"
ohos:width="match_parent"
ohos:id="$+id:home"
ohos:bottom_margin="5vp"
ohos:text_color="$color:color_f3"
ohos:element_top="$media:shouye"
ohos:text_alignment="center"
ohos:layout_alignment="center"
ohos:text_size="15fp"
ohos:text="首页"/>
</DirectionalLayout>
<DirectionalLayout
ohos:id="$+id:classlyDL"
ohos:height="match_content"
ohos:width="match_content"
ohos:top_margin="20vp"
ohos:background_element="#fff"
ohos:weight="1">
<Text
ohos:id="$+id:classly"
ohos:height="match_content"
ohos:width="match_parent"
ohos:bottom_margin="5vp"
ohos:text_color="$color:color_d0"
ohos:element_top="$media:fenlei"
ohos:text_alignment="center"
ohos:layout_alignment="center"
ohos:text_size="15fp"
ohos:text="分类"/>
</DirectionalLayout>
<DirectionalLayout
ohos:id="$+id:communityDL"
ohos:height="match_content"
ohos:width="match_content"
ohos:top_margin="20vp"
ohos:background_element="#fff"
ohos:weight="1">
<Text
ohos:id="$+id:community"
ohos:height="match_content"
ohos:width="match_parent"
ohos:bottom_margin="5vp"
ohos:text_color="$color:color_d0"
ohos:element_top="$media:sq"
ohos:text_alignment="center"
ohos:text_size="15fp"
ohos:layout_alignment="center"
ohos:text="社区"/>
</DirectionalLayout>
<DirectionalLayout
ohos:id="$+id:shopingDL"
ohos:height="match_content"
ohos:width="match_content"
ohos:top_margin="20vp"
ohos:background_element="#fff"
ohos:weight="1">
<Text
ohos:id="$+id:shoping"
ohos:height="match_content"
ohos:width="match_parent"
ohos:bottom_margin="5vp"
ohos:text_color="$color:color_d0"
ohos:element_top="$media:gwc"
ohos:text_alignment="center"
ohos:layout_alignment="center"
ohos:text_size="15fp"
ohos:text="购物车"/>
</DirectionalLayout>
<DirectionalLayout
ohos:id="$+id:myDL"
ohos:height="match_content"
ohos:width="match_content"
ohos:top_margin="20vp"
ohos:background_element="#fff"
ohos:weight="1">
<Text
ohos:id="$+id:my"
ohos:height="match_content"
ohos:width="match_parent"
ohos:bottom_margin="5vp"
ohos:text_color="$color:color_d0"
ohos:element_top="$media:my"
ohos:text_alignment="center"
ohos:layout_alignment="center"
ohos:text_size="15fp"
ohos:text="个人"/>
</DirectionalLayout>
</DirectionalLayout>
</DirectionalLayout>
public class MainAbilitySlice extends AbilitySlice {
@BindView(value = ResourceTable.Id_dl_frame)
DirectionalLayout dl_frame;
@BindView(value = ResourceTable.Id_listtenDL)
DirectionalLayout listtenDL;
@BindView(value = ResourceTable.Id_classlyDL)
DirectionalLayout classlyDL;
@BindView(value = ResourceTable.Id_communityDL)
DirectionalLayout communityDL;
@BindView(value = ResourceTable.Id_shopingDL)
DirectionalLayout shopingDL;
@BindView(value = ResourceTable.Id_myDL)
DirectionalLayout myDL;
@BindView(value = ResourceTable.Id_home)
Text home;
@BindView(value = ResourceTable.Id_classly)
Text classly;
@BindView(value = ResourceTable.Id_community)
Text community;
@BindView(value = ResourceTable.Id_shoping)
Text shoping;
@BindView(value = ResourceTable.Id_my)
Text my;
@Override
public void onStart(Intent intent) {
super.onStart(intent);
super.setUIContent(ResourceTable.Layout_ability_main);
ButterKnife.bind(this);
//默认第一个
setUI(new HomeSlice(), home);
}
@OnClick({ResourceTable.Id_home, ResourceTable.Id_classly, ResourceTable.Id_shoping, ResourceTable.Id_community, ResourceTable.Id_my})
public void click(Component component) {
System.err.println(component.getId() + "::::::::::::::::::::::");
switch (component.getId()) {
case ResourceTable.Id_home:
setUI(new HomeSlice(), home);
break;
case ResourceTable.Id_classly:
setUI(new ClasslySlice(), classly);
break;
case ResourceTable.Id_shoping:
setUI(new ShopingSlice(), shoping);
break;
case ResourceTable.Id_community:
setUI(new CommunitySlice(), community);
break;
case ResourceTable.Id_my:
setUI(new MySlice(), my);
break;
}
}
public void setUI(Fraction fraction, Text textview) {
//清空文字颜色
setTextColor(textview);
dl_frame.removeAllComponents();
//加载界面
((FractionAbility) getAbility()).getFractionManager().startFractionScheduler().add(ResourceTable.Id_dl_frame, fraction).submit();
}
//单个Item切换
public void setTextColor(Text textview) {
ResourceManager resourceManager = getAbility().getResourceManager();
Resource resource;
PixelMapElement element;
try {
int color = resourceManager.getElement(ResourceTable.Color_color_d0).getColor();
int color2 = resourceManager.getElement(ResourceTable.Color_color_f3).getColor();
clearClick(color);//清除点击事件
textview.setTextColor(new Color(color2));
if (textview == home) {//首页
resource = resourceManager.getResource(ResourceTable.Media_home1);
element = new PixelMapElement(resource);
home.setAroundElements(null, element, null, null);
} else if (textview == classly) {//分类
resource = resourceManager.getResource(ResourceTable.Media_fenlei1);
element = new PixelMapElement(resource);
classly.setAroundElements(null, element, null, null);
} else if (textview == community) {//社区
resource = resourceManager.getResource(ResourceTable.Media_sq1);
element = new PixelMapElement(resource);
community.setAroundElements(null, element, null, null);
} else if (textview == shoping) {//购物车
resource = resourceManager.getResource(ResourceTable.Media_gwc1);
element = new PixelMapElement(resource);
shoping.setAroundElements(null, element, null, null);
} else if (textview == my) {//我的
resource = resourceManager.getResource(ResourceTable.Media_my1);
element = new PixelMapElement(resource);
my.setAroundElements(null, element, null, null);
}
} catch (Exception e) {
e.printStackTrace();
}
}
//清空点击事件
public void clearClick(int color1) {
ResourceManager resourceManager = getAbility().getResourceManager();
Resource resource;
PixelMapElement element;
try {
resource = resourceManager.getResource(ResourceTable.Media_home);
element = new PixelMapElement(resource);
home.setAroundElements(null, element, null, null);
home.setTextColor(new Color(color1));
resource = resourceManager.getResource(ResourceTable.Media_fenlei);
element = new PixelMapElement(resource);
classly.setAroundElements(null, element, null, null);
classly.setTextColor(new Color(color1));
resource = resourceManager.getResource(ResourceTable.Media_sq);
element = new PixelMapElement(resource);
community.setAroundElements(null, element, null, null);
community.setTextColor(new Color(color1));
resource = resourceManager.getResource(ResourceTable.Media_gwc);
element = new PixelMapElement(resource);
shoping.setAroundElements(null, element, null, null);
shoping.setTextColor(new Color(color1));
resource = resourceManager.getResource(ResourceTable.Media_my);
element = new PixelMapElement(resource);
my.setAroundElements(null, element, null, null);
my.setTextColor(new Color(color1));
} catch (Exception e) {
e.printStackTrace();
}
}
//回退拦截
@Override
protected void onBackPressed() {
//弹出提示框
CommonDialog commonDialog = new CommonDialog(getContext());
DirectionalLayout toastLayout = (DirectionalLayout) LayoutScatter.getInstance(getContext())
.parse(ResourceTable.Layout_layout_dialog, null, false);
commonDialog.setContentCustomComponent(toastLayout);
//退出应用
Button dialog_out = (Button)toastLayout.findComponentById(ResourceTable.Id_dialog_out);
dialog_out.setClickedListener(new Component.ClickedListener() {
@Override
public void onClick(Component component) {
commonDialog.hide();
terminateAbility();
}
});
//隐藏
Button dialog_hide = (Button)toastLayout.findComponentById(ResourceTable.Id_dialog_hide);
dialog_hide.setClickedListener(new Component.ClickedListener() {
@Override
public void onClick(Component component) {
commonDialog.hide();
}
});
//再听听
Button dialog_continue = (Button)toastLayout.findComponentById(ResourceTable.Id_dialog_continue);
dialog_continue.setClickedListener(new Component.ClickedListener() {
@Override
public void onClick(Component component) {
commonDialog.hide();
}
});
commonDialog.setSize(800,410);
commonDialog.setAlignment(LayoutAlignment.CENTER);
commonDialog.show();
}
@Override
public void onActive() {
super.onActive();
}
@Override
public void onForeground(Intent intent) {
super.onForeground(intent);
}
}
就这些就可以实现了,我的这个写的比较乱