页面嵌套怎么做呢,想做个底部可切换tab的demo,
类似android的activity + viewpager + 多个fragment应该怎么搞啊?求大佬解惑。
页面嵌套
赞
收藏 0
回答 3
待解决
相关问题
后台录像需要怎么做呢?
1365浏览 • 1回复 待解决
应用的配置文件“config.json”中添加注释怎么做呢
7838浏览 • 2回复 待解决
polarDB私有化部署怎么做?
526浏览 • 1回复 待解决
选择PolarDB实例接入方式,需要怎么做?
622浏览 • 1回复 待解决
应用侧显示华为云mqtt数据是怎么做?
4558浏览 • 1回复 待解决
MQTT 服务器 怎么做压力测试,求指导?
266浏览 • 1回复 待解决
鸿蒙软键盘弹出后,页面底部的按钮
1308浏览 • 0回复 待解决
dockerfile 先构建编译环境得到目标代码后再构建目标镜像怎么做
1882浏览 • 1回复 待解决
用ETS实现语音视频通话,应该怎么做?
586浏览 • 1回复 待解决
使用TabsController 切换页面的时候,需要给目的页面传递数据要怎么实现
134浏览 • 1回复 待解决
使用JS开发一个APP,使用关系型数据库做数据的持久化该怎么做?
1263浏览 • 1回复 待解决
PageAbility配合多个Slice实现页面间切换
10517浏览 • 4回复 已解决
工具类里 怎么跳转或打开页面呢?
1172浏览 • 1回复 待解决
使用ToggleButton切换图片时底部会有黑点出现
4358浏览 • 1回复 待解决
鸿蒙tablist 如何通过滑动切换页面?
3611浏览 • 1回复 待解决
java鸿蒙Tab框架 image图片怎么渲染的
4419浏览 • 2回复 待解决
同时安装多个DevEco Studio版本,怎么做让各个版本可以不冲突
2364浏览 • 1回复 已解决
鸿蒙app开发 页面弹出了软键盘,底部的按钮被键盘挡住,有解决方案?
6921浏览 • 1回复 待解决
tab-bar下方的下划线怎么去掉?
582浏览 • 1回复 待解决
应用切换到后台再切换到前台总是在首页,没有进入上一次的操作页面
3857浏览 • 1回复 待解决
服务卡片如何跳转到指定的页面呢?
3143浏览 • 1回复 待解决
JS单个页面强制横屏或竖屏怎么设定呢?
1777浏览 • 1回复 待解决
ScrollView嵌套ListContainer
3812浏览 • 5回复 待解决
websocket结合php做数据实时展示页面
367浏览 • 1回复 待解决
鸿蒙js中,底部导航栏可以用自定义组件来做吗?
3172浏览 • 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);
}
}
就这些就可以实现了,我的这个写的比较乱