alibaba / weex

A framework for building Mobile cross-platform UI
https://weexapp.com/
Apache License 2.0
18.28k stars 2.13k forks source link

Weex怎么加载到Fragment? #2593

Closed luckyjay09 closed 3 years ago

luckyjay09 commented 7 years ago

Android使用原生导航栏 怎么让Weex渲染加载到当前Activity的Fragment中 官方只有Activity的Weex实现

CCC2016 commented 7 years ago

MainActivity 实现 AbstractWeexActivity, 在 MainActivity 中使用 FragmentTabHost 实现导航,

加载到 Fragment 中渲染:

MainActivity mainActivity = (MainActivity) getActivity();

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
    @Nullable Bundle savedInstanceState) {
    mainActivity.setContainer(customView);
    return customView;
}

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mainActivity.renderPage(WXFileUtils.loadAsset("more-lists.js", getContext()));
}

😁

luckyjay09 commented 7 years ago

AbstractWeexActivity不是抽象类吗 为什么是实现它? 楼上有没有完整点的代码 我撸不出来啊 直接用用最普通的V4包的Fragment通过按钮replace()方法 切换不同的fragment可以实现吗 还有customView是哪里来的

CCC2016 commented 7 years ago

Activity 集成 AbstractWeexActivity就好了,AbstractWeexActivity 虽然是抽象类,但没有抽象方法,不需要做额外处理; customView 只需是 ViewGroup 子类即可; 你看一遍官方 AbstractWeexActivity 类的代码就会懂了。 🙂

kevinTutu commented 7 years ago

同问 现在如何将Weex渲染加载到当前Activity的Fragment中

Tomdoog commented 7 years ago

一样我也想问,怎么把 js 渲染到fragment里 求大神啊

shinyjacklee commented 6 years ago

Hi guys, try this demo weex-start-kit to see how to load weex page in Fragment(Android)

YorkShen commented 5 years ago

This PR/issue doesn't received response since Weex migrated to Apache two years ago and this repository is no longer active yet.

Feel free to ask question in new repository and thanks for your contribution.

Hanks10100 commented 3 years ago

This issue is outdated for a long time and will be closed now. You can create a new one if you still have questions.

lihongyang166 commented 1 year ago

这个问题是否解决了,目前也遇到此类问题,参考[weex-start-kit]无法解决,是否可以给与一些帮助