how to view pdf file inside a fragment in android -
this question has answer here:
- render pdf file using java on android 7 answers
i have fragment sets text of textview, here code ;
public class pagefragment extends fragment { @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // last 2 arguments ensure layoutparams 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 want instead of text view want attach pdf reader on fragment .. possible ?
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 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 r.layout.lesson_fragment add webview init webview in oncreate call 1 of abve 2 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 file in assert folder
Comments
Post a Comment