<legend id='d5VL1'><style id='d5VL1'><dir id='d5VL1'><q id='d5VL1'></q></dir></style></legend>
    • <bdo id='d5VL1'></bdo><ul id='d5VL1'></ul>

      1. <tfoot id='d5VL1'></tfoot>
      2. <i id='d5VL1'><tr id='d5VL1'><dt id='d5VL1'><q id='d5VL1'><span id='d5VL1'><b id='d5VL1'><form id='d5VL1'><ins id='d5VL1'></ins><ul id='d5VL1'></ul><sub id='d5VL1'></sub></form><legend id='d5VL1'></legend><bdo id='d5VL1'><pre id='d5VL1'><center id='d5VL1'></center></pre></bdo></b><th id='d5VL1'></th></span></q></dt></tr></i><div id='d5VL1'><tfoot id='d5VL1'></tfoot><dl id='d5VL1'><fieldset id='d5VL1'></fieldset></dl></div>

        <small id='d5VL1'></small><noframes id='d5VL1'>

        MuPDF for Android:片段选项而不是活动

        时间:2023-10-04
          <tbody id='frhyf'></tbody>

            <legend id='frhyf'><style id='frhyf'><dir id='frhyf'><q id='frhyf'></q></dir></style></legend>

            <small id='frhyf'></small><noframes id='frhyf'>

                <bdo id='frhyf'></bdo><ul id='frhyf'></ul>
              • <tfoot id='frhyf'></tfoot>
                  <i id='frhyf'><tr id='frhyf'><dt id='frhyf'><q id='frhyf'><span id='frhyf'><b id='frhyf'><form id='frhyf'><ins id='frhyf'></ins><ul id='frhyf'></ul><sub id='frhyf'></sub></form><legend id='frhyf'></legend><bdo id='frhyf'><pre id='frhyf'><center id='frhyf'></center></pre></bdo></b><th id='frhyf'></th></span></q></dt></tr></i><div id='frhyf'><tfoot id='frhyf'></tfoot><dl id='frhyf'><fieldset id='frhyf'></fieldset></dl></div>
                • 本文介绍了MuPDF for Android:片段选项而不是活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在我现有的 android 应用程序中,我使用 MuPDF,我在 这个文档.现在,当我想在活动中打开 pdf 文件时,我使用:uri uri = Uri.parse(路径);

                  In my existing android app, Im using MuPDF, which i ported with help of this doc. Now when i want to open pdf files inside activity i use : Uri uri = Uri.parse(path);

                              Intent intent = new Intent(this, MuPDFActivity.class);
                              intent.setAction(Intent.ACTION_VIEW);
                              intent.setData(uri);
                              startActivity(intent);
                  

                  触发一个新活动,我的问题是:(1)如何启动 Fragment 来查看 pdf?(2) MuPDF 是否支持我可以在我的 currant Android-Tab-View 下调用的 Fragment?(3) 有没有办法把这个activity转化成fragment?

                  which fires a new activity, My problem is: (1) how can I start Fragment to view pdf? (2) Does MuPDF supports Fragment that I can call under my currant Android-Tab-View? (3) Is there a Way Converting this activity into fragment?

                  目前我在做:

                  public class DummySectionFragment extends Fragment {
                  
                          public DummySectionFragment() {
                          }
                  
                          @Override
                          public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
                              View  rootView = null;
                  
                              rootView = inflater.inflate(R.layout.activity_dummy_section_fragment, container, false);
                  
                              Intent myIntent = new Intent(getActivity(), MuPDFActivity.class);
                              myIntent.setAction(Intent.ACTION_VIEW);
                              myIntent.setData(uri);
                              getActivity().startActivity(myIntent); 
                  
                              return rootView;
                          }
                  }
                  

                  Which:在我当前的选项卡视图布局上打开一个新活动,它看起来不太好,因为它涵盖了整个选项卡布局并且用户必须单击 BACK 按钮才能查看选项卡视图.

                  Which: opens a new activity on my current Tab View layout, which does not look great as it covers entire tab layout and user have to click BACK button to view tab view.

                  推荐答案

                  也许你不应该在你的项目中使用 MuPDFActivity - 这只是 Mupdf 工作原理的一个例子.您需要的只是 MuPDFReaderView/MuPDFCore/MuPDFPageAdapter.MuPDFReaderView 从 View/ViewGroup 扩展,因此您可以将其添加到您的布局中.像这样尝试(完全未经测试!):

                  Maybe you shouldn't use the MuPDFActivity in your project - it's just an example how Mupdf works. All what you need is the MuPDFReaderView/MuPDFCore/MuPDFPageAdapter. MuPDFReaderView extends from View/ViewGroup, so you can just add it to your layout. Try it like this (totally untested!!):

                  1.) XML --> 片段的基本布局(mupdf_wrapper.xml):

                  1.) XML --> The base layout for the fragment (mupdf_wrapper.xml):

                  <RelativeLayout
                      android:id="@+id/mupdf_wrapper"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content">
                  </RelativeLayout>
                  

                  2.) JAVA:

                  public class DummySectionFragment extends Fragment {
                  
                      public DummySectionFragment() {
                      }
                  
                      @Override
                      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
                  
                          View  rootView = null;
                  
                          rootView = inflater.inflate(R.layout.mupdf_wrapper, container, false);
                          RelativeLayout mupdfWrapper (RelativeLayout)rootView.findViewById(R.id.mupdf_wrapper);
                          String path = "path/To/Your/PDF/File.pdf";
                          MuPDFCore core = new MuPDFCore(getActivity(), path);
                          MuPDFReaderView mDocView = new MuPDFReaderView(getActivity());
                          mDocView.setAdapter(new MuPDFPageAdapter(getActivity(), getActivity(), core));
                          mupdfWrapper .addView(mDocView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
                          return rootView;
                      }
                  

                  }

                  这篇关于MuPDF for Android:片段选项而不是活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 ActionBarSherlock &amp;ViewPagerIndicator 同步不会编译 下一篇:带有 ViewPager 的 TabLayout 在片段 Android 中不起作用

                  相关文章

                  <small id='IMdlb'></small><noframes id='IMdlb'>

                • <legend id='IMdlb'><style id='IMdlb'><dir id='IMdlb'><q id='IMdlb'></q></dir></style></legend>

                    <bdo id='IMdlb'></bdo><ul id='IMdlb'></ul>

                    <i id='IMdlb'><tr id='IMdlb'><dt id='IMdlb'><q id='IMdlb'><span id='IMdlb'><b id='IMdlb'><form id='IMdlb'><ins id='IMdlb'></ins><ul id='IMdlb'></ul><sub id='IMdlb'></sub></form><legend id='IMdlb'></legend><bdo id='IMdlb'><pre id='IMdlb'><center id='IMdlb'></center></pre></bdo></b><th id='IMdlb'></th></span></q></dt></tr></i><div id='IMdlb'><tfoot id='IMdlb'></tfoot><dl id='IMdlb'><fieldset id='IMdlb'></fieldset></dl></div>

                      <tfoot id='IMdlb'></tfoot>