0

I have a fragment that sets the text of my textview, here is my code ;

public class PageFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        // The last two arguments ensure LayoutParams are inflated
        // properly.

        View rootView = inflater.inflate(
                R.layout.lesson_fragment, container, false);
        int _parent = getArguments().getInt("parent");
        int _child = getArguments().getInt("child");
        SQLFunction _SQL = new SQLFunction();
        ((TextView) rootView.findViewById(R.id.mText1)).setText(
            _SQL.geContent(_child + 1,_parent,getActivity())
        );
        return rootView;
    }
}

now what i want to do is instead of text view I want to attach an pdf Reader on my fragment .. is it possible ?

Prudhvi
  • 2,276
  • 7
  • 34
  • 54

1 Answers1

-1
        1st method

        WebView webview = new WebView(this);
                setContentView(webview);
                webview.getSettings().setJavaScriptEnabled(true); 
                webview.getSettings().setPluginsEnabled(true); 
                webview.loadUrl("http://www.something.com/fileName.pdf"); 
                setContentView(webview); 

        2nd method

        install pdf viewer to your device first 

        Uri path = Uri.fromFile(file);
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(localpdfpath, "application/pdf");
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);

    in your  R.layout.lesson_fragment

    add webview 
    init webview in oncreate 
    call one of any abve two method

        web_viewobj=(WebView)findViewById(R.id.webView1);
             web_viewobj.getSettings().setJavaScriptEnabled(true);
               web_viewobj.getSettings().setLoadsImagesAutomatically(true);
               web_viewobj.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
             //  web_viewobj.setWebViewClient(new MyBrowser());
                  web_viewobj.loadUrl("file:///android_asset/kk2.html");

put your file in assert folder 
koutuk
  • 832
  • 1
  • 8
  • 17